Basic include() example

Written by Shai Ben-Naphtali Wednesday, 14 July 2010

Related documents:

  1. http://php.net/manual/en/function.include.php
  2. http://forum.arvixe.com/smf/general/php-script-errors/

vars.php:

<?php
$color = ‘green’;
$fruit = ‘apple’;
?>

index.php:

<?php
define(‘BASE_PATH’,'c:/hostingspaces/shai/shai-arvixe.com/wwwroot/’);
include BASE_PATH . ‘inc/vars.php’;
echo “A $color $fruit”; // A green apple
?>

Result and expected output:

A green apple


Leave a Reply






seven × = 14