Day 2


PHP Introduction Day 1
Day 2 Day 3
Day 4 Day 5

User defined functions

 

Create a PHP Function

A function will be executed by a call to the function.

Syntax

function functionName()

{

code to be executed;

}

PHP function guidelines:

  • Give the function a name that reflects what the function does
  • The function name can start with a letter or underscore (not a number)

Example

A simple function that writes my name when it is called:

<html>
<body>

<?php
function writeName()
{
echo “Welcome to website”;
}

echo “Hello Guest”;
writeName();
?>

</body>
</html>

Output:

Hello Guest Welcome to website

________________________________________

PHP Functions – Adding parameters

To add more functionality to a function, we can add parameters. A parameter is just like a variable. Parameters are specified after the function name, inside the parentheses.

 

Example 1

The following example will write different first names, but equal last name:

<html>
<body>

<?php
function writeMsg($msgs)
{
echo $msgs. “.<br />”;
}

echo “Greetings!”;
writeMsg(“Welcome”);
echo “Hello”;
writeMsg(“,Nice to meet you”);

?>

</body>
</html>

Output:

Greetings! Welcome

Hello, Nice to meet you

________________________________________

PHP Functions – Return values

To let a function return a value, use the return statement.

Example

<html>

<body>

<?php

function add($x,$y)

{

$total=$x+$y;

return $total;

}

echo “4 + 5 = ” . add(4,5);

?>

</body>

</html>

Output:

4 + 5 = 9

User-defined functions

A function may be defined using syntax such as the following:

Pseudo code to demonstrate function uses

<?php

function foo($arg_1, $arg_2, /* …, */ $arg_n)

{

echo “Example function.\n”;

return $retval;

}

?>

Any valid PHP code may appear inside a function, even other functions and class definitions.

In PHP 3, functions must be defined before they are referenced. No such requirement exists since PHP 4. Except when a function is conditionally defined such as shown in the two examples below.

When a function is defined in a conditional manner such as the two examples shown. Its definition must be processed prior to being called.

Conditional functions

<?php

$makefoo = true;

/* We can’t call foo() from here

since it doesn’t exist yet,

but we can call bar() */

bar();

if ($makefoo) {

function foo()

{

echo “I don’t exist until program execution reaches me.\n”;

}

}

/* Now we can safely call foo()

since $makefoo evaluated to true */

if ($makefoo) foo();

function bar()

{

echo “I exist immediately upon program start.\n”;

}

?>

Functions within functions

<?php

function foo()

{

function bar()

{

echo “I don’t exist until foo() is called.\n”;

}

}

/* We can’t call bar() yet

since it doesn’t exist. */

foo();

/* Now we can call bar(),

foo()’s processesing has

made it accessible. */

bar();

?>

All functions and classes in PHP have the global scope – they can be called outside a function even if they were defined inside and vice versa.

PHP does not support function overloading, nor is it possible to undefine or redefine previously-declared functions.

Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.

It is possible to call recursive functions in PHP. However avoid recursive function/method calls with over 100-200 recursion levels as it can smash the stack and cause a termination of the current script.

Recursive functions

<?php

function recursion($a)

{

if ($a < 20) {

echo “$a\n”;

recursion($a + 1);

}

}

?>

Built in functions

PHP Array Functions

These functions allow you to interact with and manipulate arrays in various ways. Arrays are essential for storing, managing, and operating on sets of variables.

array() Create an array

array_change_key_case() Returns an array with all keys in lowercase or

uppercase  array_chunk() Splits an array into chunks of arrays

array_combine() Creates an array by using one array for keys and another for its values

array_count_values() Returns an array with the number of occurrences for each value

array_diff() Compares array values, and returns the differences

array_diff_assoc() Compares array keys and values, and returns the differences

array_diff_key() Compares array keys, and returns the differences

array_diff_uassoc() Compares array keys and values, with an additionaluser-made function check, and returns the differences

array_diff_ukey() Compares array keys, with an additional user-made function check, and returns the differences

array_fill() Fills an array with values

array_fill_keys() Fill an array with values, specifying keys

 

PHP Date and Time Functions

These functions allow you to get the date and time from the server where your PHP scripts are running. You can use these functions to format the date and time in many different ways.

date_create() Returns new DateTime object

date_date_set() Sets the date

date_default_timezone_get() Returns the default time zone

date_default_timezone_set() Sets the default time zone

date_format() Returns date formatted according to given format

date_modify() Alters the timestamp

date_parse() Returns associative array with detailed info about given date

 

 

class

Every class definition begins with the keyword class, followed by a class name, which can be any name that isn’t a reserved word in PHP. Followed by a pair of curly braces, of which contains the definition of the classes members and methods. A pseudo-variable, $this is available when a method is called from within an object context. $this is a reference to the calling object (usually the object to which the method belongs, but can be another object, if the method is called statically from the context of a secondary object). This is illustrated in the following example: $this variable in object-oriented language

<?php

class A

{

function foo()

{

if (isset($this)) {

echo ‘$this is defined (‘;

echo get_class($this);

echo “)\n”;

} else {

echo “\$this is not defined.\n”;

}

}

}

class B

{

function bar()

{

A::foo();

}

}

$a = new A();

$a->foo();

A::foo();

$b = new B();

$b->bar();

B::bar();

?>

The above example will output:

$this is defined (a)

$this is not defined.

$this is defined (b)

$this is not defined.

Simple Class definition

<?php

class SimpleClass

{

// member declaration

public $var = ‘a default value’;

// method declaration

public function displayVar() {

echo $this->var;

}

}

?>

new

To create an instance of an object, a new object must be created and assigned to a variable. An object will always be assigned when creating a new object unless the object has a constructor defined that throws an exception on error.

Creating an instance

<?php

$instance = new SimpleClass();

?>

When assigning an already created instance of an object to a new variable, the new variable will access the same instance as the object that was assigned. This behaviour is the same when passing instances to a function. A new instance of an already created object can be made by cloning it.

Object Assignment

<?php

$assigned   =  $instance;

$reference  =& $instance;

$instance->var = ‘$assigned will have this value’;

$instance = null; // $instance and $reference become null

var_dump($instance);

var_dump($reference);

var_dump($assigned);

?>

The above example will output:

NULL

NULL

object(SimpleClass)#1 (1) {

[“var”]=>

string(30) “$assigned will have this value”

}

extends

A class can inherit methods and members of another class by using the extends keyword in the declaration. It is not possible to extend multiple classes, a class can only inherit one base class.

The inherited methods and members can be overridden, unless the parent class has defined a method as final, by redeclaring them within the same name defined in the parent class. It is possible to access the overrided method or members by referencing them with parent::

Simple Class Inherintance

<?php

class ExtendClass extends SimpleClass

{

// Redefine the parent method

function displayVar()

{

echo “Extending class\n”;

parent::displayVar();

}

}

$extended = new ExtendClass();

$extended->displayVar();

?>

The above example will output:

Extending class

a default value

 

Class Abstraction

PHP 5 introduces abstract classes and methods. It is not allowed to create an instance of a class that has been defined as abstract. Any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method’s signature they cannot define the implementation.

When inheriting from an abstract class, all methods marked abstract in the parent’s class declaration must be defined by the child; additionally, these methods must be defined with the same (or weaker) visibillity. For example, if the abstract method is defined as protected, the function implementation must be defined as either protected or public.

Abstract class example

<?php

abstract class AbstractClass

{

// Force Extending class to define this method

abstract protected function getValue();

abstract protected function prefixValue($prefix);

// Common method

public function printOut() {

print $this->getValue() . “\n”;

}

}

class ConcreteClass1 extends AbstractClass

{

protected function getValue() {

return “ConcreteClass1”;

}

public function prefixValue($prefix) {

return “{$prefix}ConcreteClass1”;

}

}

class ConcreteClass2 extends AbstractClass

{

public function getValue() {

return “ConcreteClass2”;

}

public function prefixValue($prefix) {

return “{$prefix}ConcreteClass2”;

}

}

$class1 = new ConcreteClass1;

$class1->printOut();

echo $class1->prefixValue(‘FOO_’) .”\n”;

$class2 = new ConcreteClass2;

$class2->printOut();

echo $class2->prefixValue(‘FOO_’) .”\n”;

?>

 

The above example will output:

 

ConcreteClass1

FOO_ConcreteClass1

ConcreteClass2

FOO_ConcreteClass2

 

Constructors and Destructors

 

Constructor

 

void __construct ( [mixed args [, …]] )

PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required.

 

using new unified constructors

 

<?php

class BaseClass {

function __construct() {

print “In BaseClass constructor\n”;

}

}

class SubClass extends BaseClass {

function __construct() {

parent::__construct();

print “In SubClass constructor\n”;

}

}

$obj = new BaseClass();

$obj = new SubClass();

?>

For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics.

 

Destructor

void __destruct ( void )

PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed.

Destructor Example

<?php

class MyDestructableClass {

function __construct() {

print “In constructor\n”;

$this->name = “MyDestructableClass”;

}

function __destruct() {

print “Destroying ” . $this->name . “\n”;

}

}

$obj = new MyDestructableClass();

?>

Like constructors, parent destructors will not be called implicitly by the engine. In order to run a parent destructor, one would have to explicitly call parent::__destruct() in the destructor body.

 

Destructor is called during the script shutdown so headers are always already sent.

 

Attempting to throw an exception from a desctructor causes a fatal error.

 

 

Visibility

The visibility of a property or method can be defined by prefixing the declaration with the keywords: public, protected or private. Public declared items can be accessed everywhere. Protected limits access to inherited and parent classes (and to the class that defines the item). Private limits visibility only to the class that defines the item.

Members Visibility

Class members must be defined with public, private, or protected.

Member declaration

 

<?php

/**

* Define MyClass

*/

class MyClass

{

public $public = ‘Public’;

protected $protected = ‘Protected’;

private $private = ‘Private’;

function printHello()

{

echo $this->public;

echo $this->protected;

echo $this->private;

}

}

$obj = new MyClass();

echo $obj->public; // Works

echo $obj->protected; // Fatal Error

echo $obj->private; // Fatal Error

$obj->printHello(); // Shows Public, Protected and Private

/**

* Define MyClass2

*/

class MyClass2 extends MyClass

{

// We can redeclare the public and protected method, but not private

protected $protected = ‘Protected2’;

function printHello()

{

echo $this->public;

echo $this->protected;

echo $this->private;

}

}

$obj2 = new MyClass2();

echo $obj->public; // Works

echo $obj2->private; // Undefined

echo $obj2->protected; // Fatal Error

$obj2->printHello(); // Shows Public, Protected2, not Private

?>

The PHP 4 method of declaring a variable with the var keyword is no longer valid for PHP 5 objects. For compatibility a variable declared in php will be assumed with public visibility, and a E_STRICT warning will be issued.

 

Method Visibility

Class methods must be defined with public, private, or protected. Methods without any declaration are defined as public.

Method Declaration

<?php

/**

* Define MyClass

*/

class MyClass

{

// Contructors must be public

public function __construct() { }

// Declare a public method

public function MyPublic() { }

// Declare a protected method

protected function MyProtected() { }

// Declare a private method

private function MyPrivate() { }

// This is public

function Foo()

{

$this->MyPublic();

$this->MyProtected();

$this->MyPrivate();

}

}

$myclass = new MyClass;

$myclass->MyPublic(); // Works

$myclass->MyProtected(); // Fatal Error

$myclass->MyPrivate(); // Fatal Error

$myclass->Foo(); // Public, Protected and Private work

/**

* Define MyClass2

*/

class MyClass2 extends MyClass

{

// This is public

function Foo2()

{

$this->MyPublic();

$this->MyProtected();

$this->MyPrivate(); // Fatal Error

}

}

$myclass2 = new MyClass2;

$myclass2->MyPublic(); // Works

$myclass2->Foo2(); // Public and Protected work, not Private

?>

 

Static Keyword

 

Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can).

The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public.

Because static methods are callable without an instance of the object created, the pseudo variable $this is not available inside the method declared as static.

In fact static method calls are resolved at compile time. When using an explicit class name the method is already identified completely and no inheritance rules apply. If the call is done by self then self is translated to the current class, that is the class the code belongs to. Here also no inheritance rules apply.

Static properties cannot be accessed through the object using the arrow operator ->.

Headers, include, require


header

(PHP 3, PHP 4, PHP 5)

header — Send a raw HTTP header

Description

void header ( string string [, bool replace [, int http_response_code]] )

header() is used to send raw HTTP headers. The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in FALSE as the second argument you can force multiple headers of the same type. For example:

<?php

header(‘WWW-Authenticate: Negotiate’);

header(‘WWW-Authenticate: NTLM’, false);

?>

The second optional http_response_code force the HTTP response code to the specified value. (This parameter is available in PHP 4.3.0 and higher.)

There are two special-case header calls. The first is a header that starts with the string “HTTP/” (case is not significant), which will be used to figure out the HTTP status code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive), you may want to make sure that your script generates the proper status code.

 

<?php

header(“HTTP/1.0 404 Not Found”);

?>

 

The HTTP status header line will always be the first sent to the client, regardless of the actual header() call being the first or not. The status may be overridden by calling header() with a new status line at any time unless the HTTP headers have already been sent.

The second special case is the “Location:” header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless some 3xx status code has already been set.

<?php

header(“Location: http://www.example.com/”); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */

exit;

?>

HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER[‘HTTP_HOST’], $_SERVER[‘PHP_SELF’] and dirname() to make an absolute URI from a relative one yourself:

<?php

header(“Location: http://” . $_SERVER[‘HTTP_HOST’]

. rtrim(dirname($_SERVER[‘PHP_SELF’]), ‘/\\’)

. “/” . $relative_url);

?>

Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant.

PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with:

<?php

header(“Cache-Control: no-cache, must-revalidate”); // HTTP/1.1

header(“Expires: Mon, 26 Jul 1997 05:00:00 GMT”); // Date in the past

?>

You may find that your pages aren’t cached even if you don’t output all of the headers above. There are a number of options that users may be able to set for their browser that change its default caching behavior. By sending the headers above, you should override any settings that may otherwise cause the output of your script to be cached.

Additionally, session_cache_limiter() and the session.cache_limiter configuration setting can be used to automatically generate the correct caching-related headers when sessions are being used.

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

<html>

<?php

/* This will give an error. Note the output

* above, which is before the header() call */

header(‘Location: http://www.example.com/’);

?>

As of PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.

If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

<?php

// We’ll be outputting a PDF

header(‘Content-type: application/pdf’);

// It will be called downloaded.pdf

header(‘Content-Disposition: attachment; filename=”downloaded.pdf”‘);

// The PDF source is in original.pdf

readfile(‘original.pdf’);

?>

There is a bug in Microsoft Internet Explorer 4.01 that prevents this from working. There is no workaround. There is also a bug in Microsoft Internet Explorer 5.5 that interferes with this, which can be resolved by upgrading to Service Pack 2 or later.

If safe mode is enabled the uid of the script is added to the realm part of the WWW-Authenticate header if you set this header (used for HTTP Authentication).

 

include()

The include() statement includes and evaluates the specified file.

The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well. Be warned that parse error in included file doesn’t cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does.

Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include “b.php” in that file, b.php is first looked in /www/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in include_path relative to the current working directory.

When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.

Basic include() example

vars.php

<?php

$color = ‘green’;

$fruit = ‘apple’;

?>

test.php

<?php

echo “A $color $fruit”; // A

include ‘vars.php’;

echo “A $color $fruit”; // A green apple

?>

If the include occurs inside a function within the calling file, then all of the code contained in the called file will behave as though it had been defined inside that function. So, it will follow the variable scope of that function.

Including within functions

 

<?php

function foo()

{

global $color;

include ‘vars.php’;

echo “A $color $fruit”;

}

/* vars.php is in the scope of foo() so     *

* $fruit is NOT available outside of this  *

* scope.  $color is because we declared it *

* as global.                               */

foo();                   // A green apple

echo “A $color $fruit”;  // A green

?>

When a file is included, parsing drops out of PHP mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags.

If “URL fopen wrappers” are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper) instead of a local pathname. If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file’s variable scope; the script is actually being run on the remote server and the result is then being included into the local script.

include() through HTTP

<?php

/* This example assumes that www.example.com is configured to parse .php

* files and not .txt files. Also, ‘Works’ here means that the variables

* $foo and $bar are available within the included file. */

// Won’t work; file.txt wasn’t handled by www.example.com as PHP

include ‘http://www.example.com/file.txt?foo=1&bar=2’;

// Won’t work; looks for a file named ‘file.php?foo=1&bar=2’ on the

// local filesystem.

include ‘file.php?foo=1&bar=2’;

// Works.

include ‘http://www.example.com/file.php?foo=1&bar=2’;

$foo = 1;

$bar = 2;

include ‘file.txt’;  // Works.

include ‘file.php’;  // Works.

?>

Security warning

Remote file may be processed at the remote server (depending on the file extension and the fact if the remote server runs PHP or not) but it still has to produce a valid PHP script because it will be processed at the local server. If the file from the remote server should be processed there and outputted only, readfile() is much better function to use. Otherwise, special care should be taken to secure the remote script to produce a valid and desired code.

Because include() and require() are special language constructs, you must enclose them within a statement block if it’s inside a conditional block.

include() and conditional blocks

<?php

// This is WRONG and will not work as desired.

if ($condition)

include $file;

else

include $other;

// This is CORRECT.

if ($condition) {

include $file;

} else {

include $other;

}

?>

Handling Returns: It is possible to execute a return() statement inside an included file in order to terminate processing in that file and return to the script which called it. Also, it’s possible to return values from included files. You can take the value of the include call as you would a normal function. This is not, however, possible when including remote files unless the output of the remote file has valid PHP start and end tags (as with any local file). You can declare the needed variables within those tags and they will be introduced at whichever point the file was included.

Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value.

Comparing return value of include

<?php

// won’t work, evaluated as include((‘vars.php’) == ‘OK’), i.e. include(”)

if (include(‘vars.php’) == ‘OK’) {

echo ‘OK’;

}

// works

if ((include ‘vars.php’) == ‘OK’) {

echo ‘OK’;

}

?>

In PHP 3, the return may not appear inside a block unless it’s a function block, in which case the return() applies to that function and not the whole file.

include() and the return() statement

return.php

<?php

$var = ‘PHP’;

return $var;

?>

noreturn.php

<?php

$var = ‘PHP’;

?>

testreturns.php

<?php

$foo = include ‘return.php’;

echo $foo; // prints ‘PHP’

$bar = include ‘noreturn.php’;

echo $bar; // prints 1

?>

$bar is the value 1 because the include was successful. Notice the difference between the above examples. The first uses return() within the included file while the other does not. If the file can’t be included, FALSE is returned and E_WARNING is issued.

If there are functions defined in the included file, they can be used in the main file independent if they are before return() or after. If the file is included twice, PHP 5 issues fatal error because functions were already declared, while PHP 4 doesn’t complain about functions defined after return(). It is recommended to use include_once() instead of checking if the file was already included and conditionally return inside the included file.

Another way to “include” a PHP file into a variable is to capture the output by using the Output Control Functions with include(). For example:

Using output buffering to include a PHP file into a string

 

<?php

$string = get_include_contents(‘somefile.php’);

function get_include_contents($filename) {

if (is_file($filename)) {

ob_start();

include $filename;

$contents = ob_get_contents();

ob_end_clean();

return $contents;

}

return false;

}

?>

In order to automatically include files within scripts, see also the auto_prepend_file and auto_append_file configuration options in php.ini.

require()

The require() statement includes and evaluates the specific file.

require() includes and evaluates a specific file. Detailed information on how this inclusion works is described in the documentation for include().

require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, don’t hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well.

Basic require() examples

<?php

require ‘prepend.php’;

require $somefile;

require (‘somefile.txt’);

?>

Prior to PHP 4.0.2, the following applies: require() will always attempt to read the target file, even if the line it’s on never executes. The conditional statement won’t affect require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed. Similarly, looping structures do not affect the behaviour of require(). Although the code contained in the target file is still subject to the loop, the require() itself happens only once.

 

Require vs Include

When you include a file with the include command and PHP cannot find it you will see an error message like the following:

PHP Code:

 

<?php

include(“noFileExistsHere.php”);

echo “Hello World!”;

?>

Display:

Warning: main(noFileExistsHere.php): failed to open stream: No such file or directory in /home/websiteName/FolderName/Script.php on line 2 Warning: main(): Failed opening ‘noFileExistsHere.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/websiteName/FolderName/Script.php on line 2

Hello World!

Notice that our echo statement is still executed, this is because a Warning does not prevent our PHP script from running. On the other hand, if we did the same example but used the require statement we would get something like the following example.

PHP Code:

<?php

require(“noFileExistsHere.php”);

echo “Hello World!”;

?>

Display:

Warning: main(noFileExistsHere.php): failed to open stream: No such file or directory in /home/websiteName/FolderName/Script.php on line 2

Fatal error: main(): Failed opening required ‘noFileExistsHere.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/websiteName/FolderName/Script.php on line 2

The echo statement was not executed because our script execution died after the require command returned a fatal error! We recommend that you use require instead of include because your scripts should not be executing if necessary files are missing or misnamed.

PHP Introduction Day 1
Day 2 Day 3
Day 4 Day 5