php echo if two conditions are true

m3tsys picture m3tsys · May 8, 2011 · Viewed 71.1k times · Source

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

Answer

Pentium10 picture Pentium10 · May 8, 2011
if (!empty($id) && file_exists($filename))