|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-12-05 16:08 UTC] rasmus at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 10 10:00:02 2026 UTC |
Hi! Look at the following 3 files: :::::::::::::: a.phtml :::::::::::::: <? require("b.phtml"); function my_function_a() { print "I'm function a!<P>\n"; my_function_b(); return true; } ?> :::::::::::::: b.phtml :::::::::::::: <? function my_function_b() { print "I'm function b!<P>"; return true; } ?> :::::::::::::: main.phtml :::::::::::::: <? require("a.phtml"); require("b.phtml"); my_function_a(); my_function_b(); ?> If you 'start' main.phtml in the browser via WWW-server you'll get the following error message: Fatal error: Can't redeclare already declared function in b.phtml on line 5 As described in the manual (and IMO) require should handle 'main.phtml' in the following way: - Replace 'require("a.phtml")' with the content of 'a.phtml'. Then 'main.phtml' should look like followed: <? require("b.phtml"); function my_function_a() { print "I'm function a!<P>\n"; my_function_b(); return true; } require("b.phtml"); my_function_a(); my_function_b(); ?> As described in the manual PHP should handle ONLY the first occurence of 'require("b.phtml")' and ignore the second occurence. But PHP seems not to detect this, if the 'require' command is split over several files, all direct or indirect included (with 'require') into the main file. Am I wrong or is this a bug? Please send me an email, if you need more information. Thanks in advance Steffen Wieschalla