cvs: phpdoc-zh /appendices migration4.xml

From: Date: Thu, 08 Aug 2002 01:52:40 +0000
Subject: cvs: phpdoc-zh /appendices migration4.xml
Groups: php.doc.zh 
Request: Send a blank email to doc-zh+get-283@lists.php.net to get a copy of this message
class007 Wed Aug 7 21:52:40 2002 EDT Modified files: /phpdoc-zh/appendices migration4.xml Log: not finished Index: phpdoc-zh/appendices/migration4.xml diff -u phpdoc-zh/appendices/migration4.xml:1.1 phpdoc-zh/appendices/migration4.xml:1.2 --- phpdoc-zh/appendices/migration4.xml:1.1 Tue Aug 6 22:07:17 2002 +++ phpdoc-zh/appendices/migration4.xml Wed Aug 7 21:52:40 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="gb2312"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <!-- $Author: class007 $ --> <!-- EN-Revision: 1.24 Maintainer: class007 Status: ready --> <appendix id="migration4"> @@ -137,101 +137,50 @@ ½âÎöºÍÖ´ÐÐÏÖÔÚ±äΪÁ½¸öÍêÈ«¶ÀÁ¢µÄ²½Öè¡£Ö»Óе±ÍêÈ«³É¹¦µÄ½âÎöºó£¬³ÌÐò²Å»áÖ´ÐС£ </para> <para> - One of the new requirements introduced with this split is that - required and included files now have to be syntactically - complete. You can no longer spread the different controlling parts - of a control structure across file boundaries. That is you cannot - start a <literal>for</literal> or <literal>while</literal> loop, - an <literal>if</literal> statement or a <literal>switch</literal> - block in one file and have the end of loop, - <literal>else</literal>, <literal>endif</literal>, - <literal>case</literal> or <literal>break</literal> statements in - a different file. - </para> - <para> - It still perfectly legal to include additional code within loops - or other control structures, only the controlling keywords and - corresponding curly braces <literal>{...}</literal> have to be - within the same compile unit (file or <function>eval</function>ed - string). - </para> - <para> - This should not harm to much as spreading code like this should be - considered as very bad style anyway. - </para> - <para> - Another thing no longer possible, though rarely seen in PHP 3 - code is returning values from a required file. Returning a value - from an included file is still possible. + ÕâÖָıäËù´øÀ´µÄÒ»¸öеÄÒªÇóÊÇÒ»¸ö½Å±¾ÎļþËù°üº¬µÄÁíÒ»¸öÎļþ±ØÐëÓÐ×ÅÍêÕûµÄÓï·¨½á¹¹¡£Äú²»Äܽ«Ò»¸öÍêÕûµÄ¿ØÖƽṹ·ÖÉ¢ÔÚ²»Í¬µÄÎļþÖС£ÕâÒâζ×ÅÄú²»ÄÜÔÚÒ»¸öÎļþÖпªÊ¼Ò»¸ö <literal>for</literal> »ò <literal>while</literal> Ñ­»·¡¢Ò»¸ö <literal>if</literal> »ò <literal>switch</literal> ¿é£¬¶øÔÚÁíÒ»¸öÎļþÖнáÊøËüÃÇ£¬»òÔÚÁíÒ»¸öÎļþÖÐʹÓà <literal>else</literal>¡¢<literal>endif</literal>¡¢<literal>case</literal> »ò <literal>break</literal>¡£ + </para> + <para> + µ«ÊÇÔÚÑ­»·»òÆäËü¿ØÖƽṹÖаüº¬¶îÍâµÄ½Å±¾ÎļþÊÇÔÊÐíµÄ¡£Ö»Òª¿ØÖƵĹؼü´ÊºÍÏàÓ¦µÄ <literal>{...}</literal> ÔÚͬһ¸öµ¥Ôª£¨Îļþ»òʹÓú¯Êý <function>eval</function> ½áºÏµÄ×Ö·û´®£©ÖоͿÉÒÔÁË¡£ + </para> + <para> + ²»¹ý£¬ÔÚÑ­»·»òÆäËü¿ØÖƽṹÖаüº¬¶îÍâµÄ½Å±¾Îļþ²¢²»ÊÇÒ»¸öºÃµÄ±é³Ìϰ¹ß¡£ + </para> + <para> + ÁíÍ⣬һÖÖÔÚ PHP 3 Öв»³£¼ûµÄ´úÂ롪¡ª´ÓÒ»¸ö require µÄÎļþÖзµ»ØÖµ¡ª¡ªÔÚ PHP 4 ÖÐÒ²²»ÄÜʹÓ᣶ø´ÓÒ»¸ö include ÎļþÖзµ»ØÖµ»¹ÊÇÔÊÐíµÄ¡£ </para> </section> <section id='migration4.error-reporting'> - <title>Error reporting</title> + <title>´íÎ󱨸æ</title> <section id='migration4.error-reporting.config'> - <title>Configuration changes</title> + <title>ÅäÖõĸıä</title> <para> - With PHP 3 the error reporting level was set as a simple - numeric value formed by summing up the numbers related to - different error levels. Usual values where 15 for reporting all - errors and warnings or 7 for reporting everything but simple - notice messages reporting bad style and things like that. + PHP 3 ´íÎ󱨸æµÄ¼¶±ðÊǼòµ¥µÄ½«²»Í¬µÄ´íÎ󱨸漶±ðµÄÊý×ÖÏà¼Ó¶ø³É¡£Í¨³£ 15 ´ú±í±¨¸æËùÓдíÎ󣬶ø 7 ´ú±í±¨¸æ³ýÁË notice ÐÅÏ¢ÒÔÍâµÄËùÓдíÎó¡£ </para> <para> - PHP 4 has a larger set of error and warning levels and comes with a - configuration parser that now allows for symbolic constants to be used - for setting the intended behavior. + PHP 4 ÓÐÒ»ÕûÌ×´íÎóºÍ¾¯¸æµÄ¼¶±ð£¬²¢ÇÒÅäÖýâÎöÆ÷ÔÊÐíʹÓ÷ûºÅ³£Á¿À´¶¨ÒåÏÔʾµÄ´íÎ󼶱𡣠</para> <para> - Error reporting level should now be configured by explicitly - taking away the warning levels you do not want to generate error - messages by x-oring them from the symbolic constant - <literal>E_ALL</literal>. Sounds complicated? Well, lets say you - want the error reporting system to report all but the simple - style warnings that are categorized by the symbolic constant - <literal>E_NOTICE</literal>. Then you'll put the following into - your &php.ini;: <literal>error_reporting = - E_ALL &amp; ~ ( E_NOTICE )</literal>. If you want to suppress - warnings too you add up the appropriate constant within the - braces using the binary or operator '|': - <literal>error_reporting= E_ALL &amp; ~ ( E_NOTICE | E_WARNING - )</literal>. + ´íÎ󱨸漶±ðÓ¦¸Ã±»Ã÷È·µÄÅäÖá£Èç¹ûÄú²»ÏëÏÔʾijÖÖ´íÎóÐÅÏ¢£¬ÄúÐèÒª½«ËûÃÇ´Ó <literal>E_ALL</literal> ·ûºÅ³£Á¿ÖÐÅųý¡£ÌýÆðÀ´ºÜ¸´ÔÓÂð£¿ÈÃÎÒÃÇ¿´¿´°É¡£Èç¹ûÄúÏëÏÔʾ³ýÁËÒÔ <literal>E_NOTICE</literal> ±íʾµÄ notice ÐÅÏ¢ÒÔÍâµÄËùÓдíÎóÐÅÏ¢£¬Äú¾ÍÓ¦¸ÃÔÚ &php.ini; ÖÐÉèÖãº<literal>error_reporting = E_ALL &amp; ~ ( E_NOTICE )</literal> ¡£Èç¹ûÄú»¹²»ÏëÏÔʾ warning ÐÅÏ¢£¬Ö»ÐèҪʹÓá°|¡±ÔËËã·û£º<literal>error_reporting= E_ALL &amp; ~ ( E_NOTICE | E_WARNING )</literal>¡£ </para> <warning> <para> - Using the old values 7 and 15 for setting up error reporting is - a very bad idea as this suppresses some of the newly added error - classes including parse errors. This may lead to very strange - behavior as scripts might no longer work without error messages - showing up anywhere. + ʹÓþÉÓÐµÄ´Ó 7 µ½ 15 µÄÊý×ÖÀ´ÉèÖôíÎ󱨸æµÄ¼¶±ð²»ÊǸöºÃÖ÷Ò⣬ÒòΪÕâÆÁ±ÎÁË PHP 4 ÖÐеĴíÎóÀà²úÉúµÄ´íÎóÐÅÏ¢¡£Õâ¿ÉÄܵ¼Ö·dz£Ææ¹ÖµÄÏÖÏ󣺽ű¾²»ÄÜÖ´ÐÐȴûÓÐÈκδíÎóÌáʾ¡£ </para> <para> - This has lead to a lot of unreproducible bug reports in the - past where people reported script engine problems they were not - capable to track down while the &true; case was usually some - missing '}' in a required file that the parser was not able to - report due to a misconfigured error reporting system. + ÕâÔÚ¹ýÈ¥ÒѾ­µ¼ÖÂÁËÐí¶àÖØ¸´µÄ bug ±¨¸æ¡£ÈËÃDZ¨¸æÐµĽű¾ÒýÇæ²»Äܸú×ٽű¾ÎļþÖо­³£·¢ÉúµÄȱÉÙ¡°}¡±µÄ´íÎó¡£ÊÂʵÉÏ£¬ÕâÊÇÓɲ»ÕýÈ·µÄÅäÖÃÒýÆðµÄ¡£ </para> <para> - So checking your error reporting setup should be the first thing - to do whenever your scripts silently die. The Zend engine can - be considered mature enough nowadays to not cause this kind of - strange behavior. + ËùÒÔ£¬¼ì²éÄú´íÎ󱨸æµÄÉèÖÃÊÇÔڽű¾ÎÞ·¨ÔËÐжøÃ»ÓгöÏÖ´íÎóÌáʾʱÄúÓ¦×öµÄµÚÒ»¼þÊ¡£Zend engine µ½ÏÖÔÚÒѾ­ºÜ³ÉÊìÁË£¬Ò»°ã²»»á³öÏÖÈç´ËÆæ¹ÖµÄÏÖÏó¡£ </para> </warning> </section> <section id='migration4.error-reporting.additions'> - <title>Additional warning messages</title> + <title>¶îÍâµÄ¾¯¸æÐÅÏ¢</title> <para> - A lot of existing PHP 3 code uses language constructs that - should be considered as very bad style as this code, while doing - the intended thing now, could easily be broken by changes in - other places. PHP 4 will output a lot of notice messages in - such situations where PHP 3 didn't. The easy fix is to just - turn off E_NOTICE messages, but it is usually a good idea to fix - the code instead. + Ðí¶àÒÑ´æÔÚµÄ PHP 3 ´úÂëʹÓõÄÓïÑÔÑùʽÔÚÏÖÔÚÓ¦µ±±»¿´×öÊǷdz£Ôã¸âµÄ¡£Òò´Ë£¬Èç¹ûÓà PHP 4 ±àÒë¸Ã½Å±¾£¬»á²úÉúºÜ¶à¶îÍâµÄ¾¯¸æÐÅÏ¢¡£Èç¹ûÄú²»Ïë¿´µ½ÕâЩÐÅÏ¢£¬Ö»Òª¼òµ¥µÄ°Ñ E_NOTICE Ñ¡Ïî¹Ø±Õ¡£µ«¸üºÃµÄ×ö·¨ÊÇÐÞÕý´úÂë¡£ </para> <para> The most common case that will now produce notice messages is the

« previous php.doc.zh (#283) next »