PHP include - Conditional

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Gene

Gene PimentelTop Member
Impact
489
Here's what I need to do... I just need someone to translate it into PHP:

If file 12345.txt exists, <?php include 'aaaaa.html'; ?>
If file 12345.txt does not exist, <?php include 'bbbbb.html'; ?>

What is the correct PHP syntax for this?

Thanks!
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Code:
<?php
$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    include("aaaaa.html")
} else {
   include("bbbb.html");
}
?>

:)
 
0
Close
That was quick! Thanks Samuel! Rep added :)
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back