很多站长朋友们都不太清楚constantphp,今天小编就来给大家整理constantphp,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 php出现T_CONSTANT_ENCAPSED_STRING错误怎么办? 2、 PHP常用函数有哪些 3、 Notice: Use of undefined constant php - assumed 'php' in 4、 php中常量的输出中,什么情况下需要用到constant(),这个函数? 5、 PHP get_defined_constants()的用法 php出现T_CONSTANT_ENCAPSED_STRING错误怎么办?define('DB_HOST','localhost');
这个定义没有错,你可以echo输出试试,没问题
Parse error: syntax error, unexpected ''); ' (T_CONSTANT_ENCAPSED_STRING) in /Applications/XAMPP/xamppfiles/htdocs/wp-config.php on line 27
具体如下:
1、程序字符串拼写错误
2、字符串连接使用 点 号 (.)
3、看一下代码里面的符号、连接等信息,仔细检查一下就可以了。
PHP常用函数有哪些常用函数比较多
如:字符串处理函数,数组函数,日期函数,MySQL函数,文件系统函数,GD函数库等
Notice: Use of undefined constant php - assumed 'php' inNotice: Use of undefined constant ALL_PS - assumed 'ALL_PS' in E:\Server\vhosts\\global.php on line 50
Notice: Undefined index: EaseTemplateVer in E:\Server\vhosts\\libs\template.core.php on line 51
Notice: Use of undefined constant uid - assumed 'uid' in E:\Server\vhosts\\global.php on line 54
Notice: Undefined index: uid in E:\Server\vhosts\\global.php on line 54
Notice: Use of undefined constant cuid - assumed 'cuid' in E:\Server\vhosts\\global.php on line 55
Notice: Undefined index: cuid in E:\Server\vhosts\\global.php on line 55
进入网站会出现大量类似下面的提示,但是可以正常显示和运行
Notice: Use of undefined constant ctbTitle - assumed 'ctbTitle' in d:\ctb1.5\ctb\include\config.php on line 23...
b答案:这些是 PHP 的提示而非报错,PHP 本身不需要事先声明变量即可直接使用,但是对未声明变量会有提示。一般作为正式的网站会把提示关掉的,甚至连错误信息也被关掉
关闭 PHP 提示的方法
搜索php.ini:
error_reporting = E_ALL
改为:
error_reporting = E_ALL ~E_NOTICE
还有个不是办法的办法就是
在每个文件头上加
error_reporting(0); 虽然不好弄但是可以解决问题
php中常量的输出中,什么情况下需要用到constant(),这个函数?常量表示不会变化的,只能赋值一次,常量的定义用define函数:define('PAI', 3.14);
echo constant('PAI'); 效果等于:echo PAI;
所以一般不用constant函数
PHP get_defined_constants()的用法array get_defined_constants ([ bool $categorize ] )
可见改函数返回值是一个数组。
例子1:
<?php
define("MY_CONSTANT", 1);
print_r(get_defined_constants(true));
?>
运行结果:
Array
(
[Core] => Array
(
[E_ERROR] => 1
[E_WARNING] => 2
[E_PARSE] => 4
[E_NOTICE] => 8
[E_CORE_ERROR] => 16
[E_CORE_WARNING] => 32
[E_COMPILE_ERROR] => 64
[E_COMPILE_WARNING] => 128
[E_USER_ERROR] => 256
[E_USER_WARNING] => 512
[E_USER_NOTICE] => 1024
[E_ALL] => 2047
[TRUE] => 1
)
[pcre] => Array
(
[PREG_PATTERN_ORDER] => 1
[PREG_SET_ORDER] => 2
[PREG_OFFSET_CAPTURE] => 256
[PREG_SPLIT_NO_EMPTY] => 1
[PREG_SPLIT_DELIM_CAPTURE] => 2
[PREG_SPLIT_OFFSET_CAPTURE] => 4
[PREG_GREP_INVERT] => 1
)
[user] => Array
(
[MY_CONSTANT] => 1
)
)
例子2:
<?php
print_r(get_defined_constants());
?>
运行结果:
Array
(
[E_ERROR] => 1
[E_WARNING] => 2
[E_PARSE] => 4
[E_NOTICE] => 8
[E_CORE_ERROR] => 16
[E_CORE_WARNING] => 32
[E_COMPILE_ERROR] => 64
[E_COMPILE_WARNING] => 128
[E_USER_ERROR] => 256
[E_USER_WARNING] => 512
[E_USER_NOTICE] => 1024
[E_ALL] => 2047
[TRUE] => 1
)
关于constantphp的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于constantphp的简单介绍的详细内容...