PHP

Articles

Files - Working with files
Excel
PDF
Access - Working with Access database
Arrays
Archives - Working with archive (zip, tar) files
Images - Working images
JSON
Charts
CAPTCHA
Functions

Quality assurance / Unit testing
Code quality
Validation
Logging
try-catch
Debugging
Debuggers
Gotchas

Dependency injection
Design patterns
Asset management
Automation
Books
Conferences
Composer
Continuous integration
CSS Preprocessors
Database versioning
Database
Sourcehunt
Editors
IDEs
Extension development
Features
Face detection
Filters
Geolocation
i18n
MVC Frameworks
Mongodb
MySQL
Vagrant

OOP
Package managers
Performance
Phing
phpdoc
Prediction
RabbitMQ
Redis
Regular expression
REST
Security
SOAP
Style Guide
Template engines
Underscore
Windows
Word

My FAQs
Socket Programming
Compile PayflowPro
old

<?php if (condition)) { ?>
    <!-- HTML content to be displayed if the condition is true -->
<?php } else { ?>
    <!-- HTML content to be displayed if the condition is false -->
<?php } ?>

<?php if (condition)): ?>
    <!-- HTML content to be displayed if the condition is true -->
<?php else: ?>
    <!-- HTML content to be displayed if the condition is false -->
<?php endif; ?>
echo (date("l, F dS Y."));
echo "This a <b>Test</b>!";
<?php
    $srcurl = "http://localhost/index.php";
    $tempfilename = "tempindex.html";
    $targetfilename = "index.html";
?>
<html><head><title>...</title></head>
<body>Generating <?php echo("$targetfilename"); ?>
<?php
    @unlink($tempfilename);
    $dynpage = fopen($srcurl,'r');
    if (! $dynpage) {
        echo "Unable to load $srcurl static page.  Aborting.";
        exit();
    }
    $htmldate = fread($dynpage, 1024 x 1024);
    fclose($dynpage);
    $tempfile = fopen($tempfilename, 'w');
    fwrite($tempfile, $htmldata);
    fclose($tempfile);
    $ok = copy($tempfilename, $targetfilename);
    unlink($tempfilename);
?>
<p>Static page successfully updated.</p>
</body></html>

How can we test to see if a variable is set?

Use the isset function:

if (isset($variableName))

What is the purpose of the $PHP_SELF variable?

It refers to the URL of the current document.

What is the purpose of the htmlspecialchars function?

$text = htmlspecialchars("<HTML> can be dangerous.");

What is the purpose of the ereg function?

ereg("PHP", $text)

What is the purpose of the eregi function?

eregi("PHP", $text);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License