What is the difference betwen Variable in PHP4 and PHP5?

筅森魡賤 提交于 2019-12-11 19:53:37

问题


the only thing i know about this subject is...

in PHP 5, when a variable used without assigned any value, then it a warning will be shown.

Is there any other difference between this 2 different version ?


回答1:


There is no general difference between variables in PHP 4 and 5.

What you are probably referring to is the ´E_NOTICE` error reporting level. When that level is turned on, PHP will complain if a variable is used that hasn't been assigned yet. That level existed in PHP 4 already:

// Report all errors except E_NOTICE
// This is the default value set in php.ini

error_reporting(E_ALL ^ E_NOTICE);

echo $hello_world;  // Will output nothing, but also not output a notice

error_reporting(E_ALL);

echo $hello_word;   // Will output "Notice: Undefined variable"

PHP's error reporting can be influenced through the "error_reporting" php.ini setting, or during runtime of the script using the error_reporting() function.

As for other differences, there's a load of them. Check out Gordon's link about Migrating from PHP 4 to 5.




回答2:


Actually, there is no real difference. An error being shown on use of undefined variables is a difference in PHP settings, not PHP version.




回答3:


There is not difference betwen variables in php4 and php5. You can stop error reporting by using this:

error_reporting('E_ALL ^ E_NOTICE'); 


来源:https://stackoverflow.com/questions/2487021/what-is-the-difference-betwen-variable-in-php4-and-php5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!