I want to call a PHP file that starts like Show
I call from the PHP like this:
I get:
Why doesn't this correctly execute the name.php file?
asked May 15, 2010 at 17:41
It's trying to run it as a shell script, which interprets your For example, in
In
Prints:
answered May 15, 2010 at 17:50
3
exec is shelling to the operating system, and unless the OS has some special way of knowing how to execute a file, then it's going to default to treating it as a shell script or similar. In this case, it has no idea how to run your php file. If this script absolutely has to be executed from a shell, then either execute php passing the filename as a parameter, e.g
or use the punct at the top of your php script
answered May 15, 2010 at 17:54
Mark BakerMark Baker 206k31 gold badges338 silver badges380 bronze badges 1 Sounds
like you're trying to execute the PHP code directly in your shell. Your shell doesn't speak PHP, so it interprets your PHP code as though it's in your shell's native language, as though you had literally run Shell scripts usually start with a "shebang" line that tells the shell what program to use to interpret the file. Begin your file like this:
Besides that, the string you're passing to Copy the contents of the command string and paste them at your command line. If it doesn't run there, then Another option is to change the command you execute. Instead of running the script directly, run
answered May 15, 2010 at 17:50
Rob KennedyRob Kennedy 160k21 gold badges273 silver badges461 bronze badges 2 This came across while working on a project on linux platform.
This runs as if you run the script from browser.
Dharman♦ 28k21 gold badges75 silver badges127 bronze badges answered Jan 7, 2014 at 6:18
AmarAmar 2,1011 gold badge12 silver badges16 bronze badges 2 How can I call one PHP file from another PHP file?It is possible to insert the content of one PHP file into another PHP file (before the server executes it), with the include or require statement. The include and require statements are identical, except upon failure: require will produce a fatal error (E_COMPILE_ERROR) and stop the script.
What is __ DIR __ in PHP?The __DIR__ can be used to obtain the current code working directory. It has been introduced in PHP beginning from version 5.3. It is similar to using dirname(__FILE__). Usually, it is used to include other files that is present in an included file.
What is include () in PHP?The Include() function is used to put data of one PHP file into another PHP file. If errors occur then the include() function produces a warning but does not stop the execution of the script i.e. the script will continue to execute. Example. First of all we create a PHP file.
How do I open a PHP file in PHP?Go to the location of your PHP file, then click the PHP file to select it. Click Open. It's in the bottom-right corner of the window.
|