“CMD menjalankan file php” Kode Jawaban

Jalankan server PHP

cd path/to/your/app
php -S localhost:8000
Mysterious Moth

cara mengeksekusi perintah cmd di php


I'm not sure what shell you are going to get with this function, but you can find out like this:

<?php
$cmd = 'set';
echo "<pre>".shell_exec($cmd)."</pre>";
?>

On my FreeBSD 6.1 box I get this:

USER=root
LD_LIBRARY_PATH=/usr/local/lib/apache2:
HOME=/root
PS1='$ '
OPTIND=1
PS2='> '
LOGNAME=root
PPID=88057
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
SHELL=/bin/sh
IFS='     
'

Very interesting.  Note that the PATH may not be as complete as you need.  I wanted to run Ghostscript via ImageMagik's "convert" and ended up having to add my path before running the command:

<?php
$cmd = 'export PATH="/usr/local/bin/"; convert -scale 25%x25% file1.pdf[0] file2.png 2>&1';
echo "<pre>".shell_exec($cmd)."</pre>";
?>

ALSO, note that shell_exec() does not grab STDERR, so use "2>&1" to redirect it to STDOUT and catch it.
Annoying Aardvark

CMD menjalankan file php

// terminal run php file
// First run "php" in the terminal, in the path directory
php
// If php works there. Then :
php path_to_file/file_name.php

//This will run your php and print stuff to your console in plain text.
//It's useful for a range of testing and data maniplation purposes. 
//And has the full php cammand line. So potential is up to your imagination.
13Garth

Bagaimana cara menjalankan skrip PHP dari baris perintah?

To execute a php script, use the PHP Command Line interface(CLI) and specify the file name of the script in the following way:
php script.php
nk

Jawaban yang mirip dengan “CMD menjalankan file php”

Pertanyaan yang mirip dengan “CMD menjalankan file php”

Lebih banyak jawaban terkait untuk “CMD menjalankan file php” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya