1 year ago
#359821
ilernet2
PHP - include and fopen
I have a small script that if you run it locally (windows) or on the server where I have deployed the code, it works fine.
It does 2 things, on the one hand I include some of its own classes and on the other hand I make a "fopen" of an html file in this way.
Include
include('Class/MysqlClass.php');
include('Class/UtilsClass.php');
Fopen
$handle=fopen("../Templates/email_esp.html","rb");
As I comment in local as in remote if I execute this script from the script directory it does not give problems of ROUTES
The problem is if I run it from cron with this statement
*/30 16-17 * * 1-6 su -c 'php /var/www/html/test_project/index.php' -s /bin/sh www-data
Then it tells me that it does not find the classes. Instead if I put the relative path of the server type this if it works
include('/var/www/html/test_project/Class/MysqlClass.php');
And the same for fopen
$handle=fopen("/var/www/html/test_project/Templates/email_esp.html","rb");
php
php-7
php-7.2
php-7.3
0 Answers
Your Answer