Skip to content
Advertisement

PHP passthru execution status

I’m trying to use the PHP passthru function to execute an OS command on Linux.

I am using it as follows. The Linux command is just to list files in a directory I know does not exist and then I am just echoing the status to make sure it’s not 0.

JavaScript

However the status seems to be the entire output of the command including the status number

JavaScript

Why is this?

Advertisement

Answer

You are seeing stderr plus the $status value. To hide stderr you could do the following:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement