Stupid question, this code:
<?php
$variable = system("cat /home/maxor/test.txt");
echo $variable;
?>
with file test.txt:
blah
prints:
blah
blah
What can I do with system() function to not print nothing so I get 1 "blah"???
According to the manual -- see system() :
system()is just like the C version of the function in that it executes the given command and outputs the result.
Which explains the first blah
Returns the last line of the command output on success
And you are echoing the returned value -- which explains the second blah.
The first one will get you all the lines of the output to an array (see the second paramater) ; and the second one will get you the full output as a string.
system is calling the actual cat program, which is outputting "blah" from test.txt. It also returns the value back to $variable which you're then printing out again.
Use exec or shell_exec instead of system.