NameSilo

PHP include - Conditional

Spaceship Spaceship
Watch

Gene

Gene PimentelTop Member
Impact
485
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Code:
<?php
$filename = '/path/to/foo.txt';

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

:)
 
0
•••
That was quick! Thanks Samuel! Rep added :)
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back