<?php
//设置错误级别。E_ALL但是除了NOTICE
error_reporting(E_ALL&~E_NOTICE);
//永久转换
//得到变量的类型
$var = 123;
var_dump($var);
echo gettype($var);
echo '<br>';
$var = true;
echo gettype($var);
echo '<br>';
//永久转换settype($var,$type)
$var = 123;
var_dump($var);
//对$var做了一个手术,变成布尔类型
settype($var,'bool');
var_dump($var);
/*
* type 的可能值为:
“boolean” (或为“bool”,从 PHP 4.2.0 起)
“integer” (或为“int”,从 PHP 4.2.0 起)
“float” (只在 PHP 4.2.0 之后可以使用,对于旧版本中使用的“double”现已停用)
"string"
"array"
"object"
“null” (从 PHP 4.2.0 起)
*
*/
$var = '3king';
settype($var,'int');
var_dump($var);
echo '<br>';
/*
*
* PHP Warning(警告): settype(): Invalid(非法) type in I:\WWW\PHPjicurumen\type-5.php on line 56
*
*/
$var = 12.3;
//手术失败
settype($var,'king');
var_dump($var);
?>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!