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
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.
The nested if statement contains the if block inside another if block. The inner if statement executes only when specified condition in outer if statement is true.
In PHP we have the following conditional statements: if statement - executes some code if one condition is true. if...else statement - executes some code if a condition is true and another code if that condition is false. if...elseif...else statement - executes different codes for more than two conditions.
The endif keyword is used to mark the end of an if conditional which was started with the if(...): syntax. It also applies to any variation of the if conditional, such as if... elseif and if...else .
if (!empty($id) && file_exists($filename))
Just use the AND
or &&
operator to check two conditions:
if (file_exists($filename) AND ! empty($id)): // do something
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With