Bug #2918: require doesn't work like described in manual

From: Date: Sun, 05 Dec 1999 20:29:26 +0000
Subject: Bug #2918: require doesn't work like described in manual
Groups: php.dev 
Request: Send a blank email to php-dev+get-13455@lists.php.net to get a copy of this message
From: django@informatik.uni-tuebingen.de Operating system: Redhat Linux 6.0 (intel) PHP version: 3.0.12 PHP Bug Type: Misbehaving function Bug description: require doesn't work like described in manual 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

« previous php.dev (#13455) next »