Read a .php file using php

后端 未结 3 1781
暗喜
暗喜 2021-01-14 18:01

How to read a .php file using php

3条回答
  •  Happy的楠姐
    2021-01-14 18:54

    //get the real path of the file in folder if necessary
    $path = realpath("/path/to/myfilename.php");
    
    //read the file
    $lines = file($path,FILE_IGNORE_NEW_LINES);
    

    Each line of the 'myfilename.php' will be stored as a string in the array '$lines'. And then, you may use all string functions in php. More info about available string functions is available here: http://www.php.net/manual/en/ref.strings.php

提交回复
热议问题