I want to call a PHP file that starts like
<?php
function connection () {
//Statements
}
I call from the PHP like this:
<?php
exec ('/opt/lampp/htdocs/stuff/name.php');
?>
I get:
line1-> cannot open ?: No such file
line 3 //Connection: not found
line 4 Syntax errror: "("
Why doesn’t this correctly execute the name.php file?
It’s trying to run it as a shell script, which interprets your
<?phptoken as bash, which is a syntax error. Just useinclude()or one of its friends:For example, in
a.phpput:In
b.phpput:Prints: