简体   繁体   中英

Execute shell command from PHP

I want to run some command from php code. When I run code from terminal it works fine without error. But when I run same command from php code it gives me error like this:

/usr/bin/php: /opt/lampp/lib/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by /usr/bin/php)

I run command : locate libxml2.so , this command gives output like this:

/opt/lampp/lib/libxml2.so
/opt/lampp/lib/libxml2.so.2
/opt/lampp/lib/libxml2.so.2.8.0
/usr/lib/i386-linux-gnu/libxml2.so
/usr/lib/i386-linux-gnu/libxml2.so.2
/usr/lib/i386-linux-gnu/libxml2.so.2.9.0

So, seems like 2.9.0 version is already installed. So, how to execute command without this error?

Use shell_exec function to exec it. Try <?php echo shell_exec('locate libxml2.so');

Finally I succeed. Install phpcs (or any module you want to execute by apache of xampp) then install inside "bin" of xampp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM