[PHP-DOC] #28827 [NEW]: The example PHP code in docs http://php.net/gmp/ crashes PHP
From: valyala at tut dot by Operating system: any PHP version: 4.3.7 PHP Bug Type: Documentation problem Bug description: The example PHP code in docs http://php.net/gmp/ crashes PHP Description: The following example code, which will calculate factorial of 1000 (pretty big number) very fast on documentation page http://php.net/gmp/ crashes PHP. --- ?php function fact($x) { if ($x = 1) { return 1; } else { return gmp_mul($x, fact($x-1)); } } echo gmp_strval(fact(1000)) . \n; ? --- The next PHP code avoids the crash: --- ?php function fact($x) { $result = 1; while ($x 1) { $result = gmp_mul($result, $x--); } return $result; } echo gmp_strval(fact(1000)) . \n; } ? --- This bug related to the following bugs: #7720, #15522, #26212. It seems that PHP4.3.7 (and older) don't handle stack overflow during function calls. You can find the maximum recursion depth for your version of PHP independently. Just play with $rec_depth number in the following script: --- ?php function f($n) { if (--$n) f($n); } /* adjust this number to find the maximum recursion depth */ $rec_depth = 1000; f($rec_depth); ? --- p.s. Are the volunteers in PHP developement team, who wanted to track stack overflow problem? Reproduce code: --- see above Expected result: decimal view of 1000! Actual result: -- PHP crash -- Edit bug report at http://bugs.php.net/?id=28827edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28827r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28827r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28827r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28827r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28827r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28827r=needscript Try newer version: http://bugs.php.net/fix.php?id=28827r=oldversion Not developer issue:http://bugs.php.net/fix.php?id=28827r=support Expected behavior: http://bugs.php.net/fix.php?id=28827r=notwrong Not enough info:http://bugs.php.net/fix.php?id=28827r=notenoughinfo Submitted twice:http://bugs.php.net/fix.php?id=28827r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28827r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28827r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28827r=dst IIS Stability: http://bugs.php.net/fix.php?id=28827r=isapi Install GNU Sed:http://bugs.php.net/fix.php?id=28827r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28827r=float
Re: [PHP-DOC] Predefinded Interfaces
This ones are predefinded by the zend engine: Traversable IteratorAggregate Iterator ArrayAccess All these four are part of the engine. (They were in a different form part of spl a long time ago). Should those predifined interfaces go to an appendix? Friedhelm The subject of interfaces/iterators/etc... is difficult to document, as this is new to PHP. Those interface are used by SPL, that implements them. I don't really know if they are usefull to a user... For example, Transversable is just: interface Traversable { } This interface *cannot* be used by PHP scripts, so there is no point in documenting it (maybe it can go to the developpers manual). The interface is something like: interface Iterator extends Traversable { function rewind(); function current(); function key(); function next(); function valid(); } Why do you need this? Maybe someone could explain me, but it seems pretty unusefull More info at great Marcus' website: interfaces: http://marcus-boerger.de/php/ext/spl/spl.phps SPL docs: http://marcus-boerger.de/php/ext/spl/html/ or http://marcus-boerger.de/php/ext/spl/spl.chm Nuno
[PHP-DOC] #28827 [Opn-Fbk]: The example PHP code in docs http://php.net/gmp/ crashes PHP
ID: 28827 Updated by: [EMAIL PROTECTED] Reported By: valyala at tut dot by -Status: Open +Status: Feedback Bug Type: Documentation problem Operating System: any PHP Version: 4.3.7 New Comment: The example from docs works perfectly with latest PHP5 PHP4. Concerning stack overflows, read php-dev archives. For example this post: http://lists.php.net/article.php?group=php.internalsarticle=8851 and all the tread: http://lists.php.net/article.php?group=php.internalsarticle=8840 Short version: this is expected behaviour. Previous Comments: [2004-06-18 12:23:54] valyala at tut dot by Description: The following example code, which will calculate factorial of 1000 (pretty big number) very fast on documentation page http://php.net/gmp/ crashes PHP. --- ?php function fact($x) { if ($x = 1) { return 1; } else { return gmp_mul($x, fact($x-1)); } } echo gmp_strval(fact(1000)) . \n; ? --- The next PHP code avoids the crash: --- ?php function fact($x) { $result = 1; while ($x 1) { $result = gmp_mul($result, $x--); } return $result; } echo gmp_strval(fact(1000)) . \n; } ? --- This bug related to the following bugs: #7720, #15522, #26212. It seems that PHP4.3.7 (and older) don't handle stack overflow during function calls. You can find the maximum recursion depth for your version of PHP independently. Just play with $rec_depth number in the following script: --- ?php function f($n) { if (--$n) f($n); } /* adjust this number to find the maximum recursion depth */ $rec_depth = 1000; f($rec_depth); ? --- p.s. Are the volunteers in PHP developement team, who wanted to track stack overflow problem? Reproduce code: --- see above Expected result: decimal view of 1000! Actual result: -- PHP crash -- Edit this bug report at http://bugs.php.net/?id=28827edit=1
[PHP-DOC] Clarification on the manual license in regards to distribution
Hello, I'm currently creating a version of the PHP 4 documentation for the RoadLingua dictionary system for handhelds (http://www.absoluteword.com). This is primarily for personal usage, but since I figure there might be others who could use it, I would like to ask if I'm allowed to distribute the dictionary as freeware, as long as I make sure the copyright information is in the file? Currently the early version of the dictionary that I've made so far, has the following notice in the About box for it: PHP 4 Manual. Copyright (c) 2003 the PHP Documentation Group (RoadLingua Version by Tristan Bendixen) I hope I'll a clear reply to my inquiry, since I will only distribute it with permission from the author(s) of the manual. Regards, Tristan Bendixen
[PHP-DOC] cvs: phpdoc /en/reference/bzip2/functions bzcompress.xml bzdecompress.xml
baoengb Fri Jun 18 11:18:38 2004 EDT Modified files: /phpdoc/en/reference/bzip2/functionsbzcompress.xml bzdecompress.xml Log: minor changes http://cvs.php.net/diff.php/phpdoc/en/reference/bzip2/functions/bzcompress.xml?r1=1.5r2=1.6ty=u Index: phpdoc/en/reference/bzip2/functions/bzcompress.xml diff -u phpdoc/en/reference/bzip2/functions/bzcompress.xml:1.5 phpdoc/en/reference/bzip2/functions/bzcompress.xml:1.6 --- phpdoc/en/reference/bzip2/functions/bzcompress.xml:1.5 Thu Jun 17 08:09:53 2004 +++ phpdoc/en/reference/bzip2/functions/bzcompress.xml Fri Jun 18 11:18:37 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.5 $ -- +!-- $Revision: 1.6 $ -- !-- splitted from ./en/functions/bzip2.xml, last change in rev 1.1 -- refentry id=function.bzcompress refnamediv @@ -34,10 +34,18 @@ value. Regardless of the parameterworkfactor/parameter, the generated output is the same. /para + /refsect1 + refsect1 +reftitle.seealso; para - example - titlefunctionbzcompress/function example/title - programlisting role=php + functionbzdecompress/function. +/para + /refsect1 + refsect1 +titleExample/title +example + titleCompressing data/title + programlisting role=php ![CDATA[ ?php $str = sample data; @@ -45,12 +53,8 @@ echo $bzstr; ? ]] - /programlisting + /programlisting /example -/para -para - See also functionbzdecompress/function. -/para /refsect1 /refentry http://cvs.php.net/diff.php/phpdoc/en/reference/bzip2/functions/bzdecompress.xml?r1=1.6r2=1.7ty=u Index: phpdoc/en/reference/bzip2/functions/bzdecompress.xml diff -u phpdoc/en/reference/bzip2/functions/bzdecompress.xml:1.6 phpdoc/en/reference/bzip2/functions/bzdecompress.xml:1.7 --- phpdoc/en/reference/bzip2/functions/bzdecompress.xml:1.6Thu Jun 17 08:09:53 2004 +++ phpdoc/en/reference/bzip2/functions/bzdecompress.xmlFri Jun 18 11:18:37 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.6 $ -- +!-- $Revision: 1.7 $ -- !-- splitted from ./en/functions/bzip2.xml, last change in rev 1.1 -- refentry id=function.bzdecompress refnamediv @@ -23,9 +23,17 @@ roughly half the speed. See the ulink url=url.bzip2;bzip2 documentation/ulink for more information about this feature. /para + /refsect1 + refsect1 +reftitle.seealso; para + functionbzcompress/function. +/para + /refsect1 + refsect1 +titleExample/title example - titlefunctionbzdecompress/function example/title + titleDecompressing a String/title programlisting role=php ![CDATA[ ?php @@ -44,10 +52,6 @@ ]] /programlisting /example -/para -para - functionbzcompress/function. -/para /refsect1 /refentry
Re: [PHP-DOC] Predefinded Interfaces
Hi, This ones are predefinded by the zend engine: Traversable IteratorAggregate Iterator ArrayAccess All these four are part of the engine. (They were in a different form part of spl a long time ago). Should those predifined interfaces go to an appendix? Friedhelm The subject of interfaces/iterators/etc... is difficult to document, as this is new to PHP. yes, maybe, but this is no valid reason to _not_ document them ;-) Those interface are used by SPL, that implements them. I don't really know if they are usefull to a user... Yes maybe they are used by SPL, but as Marcus said, these interfaces are defined by the Zend Engine 2 (read his answer above), and of course they are usefull. For example, Transversable is just: interface Traversable { } This interface *cannot* be used by PHP scripts, so there is no point in documenting it (maybe it can go to the developpers manual). The interface is something like: interface Iterator extends Traversable { function rewind(); function current(); function key(); function next(); function valid(); } Why do you need this? Maybe someone could explain me, but it seems pretty unusefull Please have a look at http://www.php.net/zend-engine-2.php the section Iteration to see how this can be usefull for userland PHP-Skripts. More info at great Marcus' website: interfaces: http://marcus-boerger.de/php/ext/spl/spl.phps SPL docs: http://marcus-boerger.de/php/ext/spl/html/ or http://marcus-boerger.de/php/ext/spl/spl.chm Thx, I know ;-) Friedhelm
Re: [PHP-DOC] Clarification on the manual license in regards to distribution
Hi Tristan. Please ask license related questions at [EMAIL PROTECTED] Thanks, Gabor Hojtsy Hello, I'm currently creating a version of the PHP 4 documentation for the RoadLingua dictionary system for handhelds (http://www.absoluteword.com). This is primarily for personal usage, but since I figure there might be others who could use it, I would like to ask if I'm allowed to distribute the dictionary as freeware, as long as I make sure the copyright information is in the file? Currently the early version of the dictionary that I've made so far, has the following notice in the About box for it: PHP 4 Manual. Copyright (c) 2003 the PHP Documentation Group (RoadLingua Version by Tristan Bendixen) I hope I'll a clear reply to my inquiry, since I will only distribute it with permission from the author(s) of the manual. Regards, Tristan Bendixen
[PHP-DOC] cvs: phpdoc /en language-snippets.ent /en/features remote-files.xml
betzFri Jun 18 13:10:47 2004 EDT Modified files: /phpdoc/en language-snippets.ent /phpdoc/en/features remote-files.xml Log: common agreement, we do not want to use literalPHP/literal in the en tree http://cvs.php.net/diff.php/phpdoc/en/language-snippets.ent?r1=1.101r2=1.102ty=u Index: phpdoc/en/language-snippets.ent diff -u phpdoc/en/language-snippets.ent:1.101 phpdoc/en/language-snippets.ent:1.102 --- phpdoc/en/language-snippets.ent:1.101 Thu Jun 17 11:12:45 2004 +++ phpdoc/en/language-snippets.ent Fri Jun 18 13:10:46 2004 @@ -1,4 +1,4 @@ -!-- $Revision: 1.101 $ -- +!-- $Revision: 1.102 $ -- !-- Keep 'em sorted -- @@ -294,7 +294,6 @@ extension in order to use these functions./simpara' !-- These are here as helpers for manual consistency and brievety-- -!ENTITY php 'literalPHP/literal' !ENTITY safemode 'link linkend=ini.safe-modesafe mode/link' !-- Notes for SAPI/Apache -- http://cvs.php.net/diff.php/phpdoc/en/features/remote-files.xml?r1=1.24r2=1.25ty=u Index: phpdoc/en/features/remote-files.xml diff -u phpdoc/en/features/remote-files.xml:1.24 phpdoc/en/features/remote-files.xml:1.25 --- phpdoc/en/features/remote-files.xml:1.24Thu May 20 18:40:42 2004 +++ phpdoc/en/features/remote-files.xml Fri Jun 18 13:10:47 2004 @@ -1,5 +1,5 @@ ?xml version=1.0 encoding=iso-8859-1? -!-- $Revision: 1.24 $ -- +!-- $Revision: 1.25 $ -- chapter id=features.remote-files titleUsing remote files/title @@ -12,7 +12,7 @@ functioninclude_once/function, functionrequire/function and functionrequire_once/function statements. See xref linkend=wrappers/ for more information about the protocols - supported by php;. + supported by PHP. /para note para
Re: [PHP-DOC] cvs: phpdoc /en/reference/array/functions array.xml
+ As in Perl, you can access a value from the array inside double quotes. + However, with PHP you'll need to enclose your array between curly braces. + example + titleAccessing an array inside double quotes/title + programlisting role=php +![CDATA[ +?php + +$foo = array('bar' = 'baz'); +echo Hello {$foo['bar']}!; // Hello baz! + +? +]] Should we also write about the following? a) $arr[foo] is fine for array key 'foo', no E_NOTICE here b) {$arr['foo']} is the same as (a) above, and preferred c) {$arr[foo]} checks for a constant named foo, not 'foo', and if no constant named foo exists throw E_NOTICE but still works d) and of course $arr['foo'] gives us a parse error (except in 4.3.0-1 it throws a strange E_NOTICE (and does not work) but we don't need to worry about that ;-) This sort of information already lives within the types section of the manual (for both array and strings) but since the array() docs were recently edited I wonder if it should include even more information as opposed to just partial information as one doesn't need to use curly braces here (as suggested by the example), it's just a preferred method. These sorts of questions do come up a lot and I think it should even be mentioned in the tutorial and/or faq especially since people use superglobals all over the place these days. What do you guys think? Regards, Philip
Re: [PHP-DOC] cvs: phpdoc /en/reference/array/functions array.xml
Should we also write about the following? a) $arr[foo] is fine for array key 'foo', no E_NOTICE here b) {$arr['foo']} is the same as (a) above, and preferred c) {$arr[foo]} checks for a constant named foo, not 'foo', and if no constant named foo exists throw E_NOTICE but still works d) and of course $arr['foo'] gives us a parse error (except in 4.3.0-1 it throws a strange E_NOTICE (and does not work) but we don't need to worry about that ;-) This sort of information already lives within the types section of the manual (for both array and strings) but since the array() docs were recently edited I wonder if it should include even more information as opposed to just partial information as one doesn't need to use curly braces here (as suggested by the example), it's just a preferred method. These sorts of questions do come up a lot and I think it should even be mentioned in the tutorial and/or faq especially since people use superglobals all over the place these days. What do you guys think? Just link the types section in here. Goba