array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.settype.php', 1 => 'settype', 2 => 'Set the type of a variable', ), 'up' => array ( 0 => 'ref.var.php', 1 => 'Variable handling Функції', ), 'prev' => array ( 0 => 'function.serialize.php', 1 => 'serialize', ), 'next' => array ( 0 => 'function.strval.php', 1 => 'strval', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/var/functions/settype.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
settype — Set the type of a variable
varThe variable being converted.
type
Possibles values of type are:
Приклад #1 settype() example
<?php
$foo = "5bar"; // string
$bar = true; // boolean
settype($foo, "integer"); // $foo is now 5 (integer)
settype($bar, "string"); // $bar is now "1" (string)
var_dump($foo, $bar);
?>Зауваження:
Maximum value for "int" is
PHP_INT_MAX.