note 83176 added to function.include

From: Date: Wed, 14 May 2008 11:01:38 +0000
Subject: note 83176 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-139368@lists.php.net to get a copy of this message
A note about the "return - thing": test2.php <?php $r = true; return $r; ?> test1.php: (Does NOT work) <?php function functionA(){ return functionB(); } function functionB(){ require_once 'test2.php'; } var_dump(functionA()); ?> When you call test1.php, result will be NULL. You have to "return" the include like this: test1.php CORRECT: <?php function functionA(){ return functionB(); } function functionB(){ return require_once 'test2.php'; } var_dump(functionA()); ?> ---- Server IP: 217.160.72.57 Probable Submitter: 85.8.70.98 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/83176 Del: integrated -- https://master.php.net/note/delete/83176/integrated Del: useless -- https://master.php.net/note/delete/83176/useless Del: bad code -- https://master.php.net/note/delete/83176/bad+code Del: spam -- https://master.php.net/note/delete/83176/spam Del: non-english -- https://master.php.net/note/delete/83176/non-english Del: in docs -- https://master.php.net/note/delete/83176/in+docs Del: other reasons-- https://master.php.net/note/delete/83176 Reject -- https://master.php.net/note/reject/83176 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139368) next »