Why the code below:
echo "Usage: " basename($_SERVER["SCRIPT_FILENAME"], '.php') "<arg2> <arg1>";
produces the following syntax error:
PHP Parse error: syntax error, unexpected 'basename' (T_STRING), expecting ',' or ';'
You should concatenate with . operator to provide the string as 1 argument to echo:
echo "Usage: " . basename($_SERVER["SCRIPT_FILENAME"], '.php') . "<arg2> <arg1>";
or use , to provide as multiple :
echo "Usage: ", basename($_SERVER["SCRIPT_FILENAME"], '.php'), "<arg2> <arg1>";
echo __FILE__; //to get the current filename.
So your code becomes:
if($argc!=3){
echo "Usage: ".__FILE__.".php <arg2> <arg1>";
die;
}
basename() function does.