php - How to use include() properly? -
this structure directory:
main directory all.php file.php url1.txt subdirectory1 url2.txt file.php
file file.php this:
$filename = glob("url*"); echo $filename[0];
file all.php
<?php include('./subdirectory1/file.php'); ?>
the problem when run file all.php, browser show url1.txt. why doesn't show url2.txt. how fix ? thank !
working directory set main script location. try putting full path of location want search in:
$filename = glob(__dir__ . directory_separator . 'url*');
__dir__
current file directory (since php 5.3, lower php version use dirname(__file__)
).
Comments
Post a Comment