The actual code looks like this:
if (file_exists($filename)) {echo $player;
} else {
echo 'something';
but it displays the player even if the id is not called from the url
i need something like this:
check if $filename exists and $id it is not empty then echo $player
if else echo something else
i check if $id is not empty with
if(empty($id)) echo "text";
but i don't know how to combine both of them
Can somebody help me?
Thank you for all your code examples but i still have a problem:
How i check if $id is not empty then echo the rest of code
You need the logical
AND
operator:Using ternary operator:
Using if-else clause:
Just use the
AND
or&&
operator to check two conditions:It's fundamental PHP. Reading material:
http://php.net/manual/en/language.operators.logical.php
http://www.php.net/manual/en/language.operators.precedence.php
you need to check
$id
along withfile_exists($filename)
as follows