note 127106 deleted from function.include-once by girgias
| From: | girgias@php.net | Date: | Tue, 17 May 2022 10:28:33 +0000 |
| Subject: | note 127106 deleted from function.include-once by girgias | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218481@lists.php.net to get a copy of this message | ||
Note Submitter: bobray99 at gmail dot com
----
Be careful when using include_once and require_once for files that return a value:
fiddle2.php
<?php
return "Some String";
fiddle.php
<?php
$s = include_once('fiddle2.php');
echo "\n" . $s;
$s = include_once('fiddle2.php');
echo "\n" . $s;
/* output
Some String
1
*/
The second time include_once occurs, it returns 1 because the file has already been included.