Free Computer Books

   »    Free Computer Books on Computer Programming, Web Development & Designing

Computer Education, Training & Tutorial Resources - ComputerEducationWorld.com
Home » Free Computer Books »

2.5 Basic Data Types
21
Examples:
‘Hello, World’
‘Today\’s the day’
2.5.3.3 Here-Docs
Here-docs enable you to embed large pieces of text in
your scripts, which may include lots of double quotes and single quotes, with-
out having to constantly escape them.
The following is an example of a here-doc:
<<<THE_END
PHP stands for “PHP: Hypertext Preprocessor”.
The acronym “PHP” is therefore, usually referred to as a recursive acronym
because the long form contains the acronym itself.
As this text is being written in a here-doc there is no need to escape the
double quotes.
THE_END
The strings starts with <<<, followed by a string that you know doesn’t
appear in your text. It is terminated by writing that string at the beginning of
a line, followed by an optional semicolon (;), and then a required newline (\n).
Escaping and variable substitution in here-docs is identical to double-quoted
strings except that you are not required to escape double quotes.

(more…)


• • •
 

PHP 5 Basic Language
“A language that doesn’t have everything is actually easier to
program in than some that do.”–Dennis M. Ritchie
2.1 INTRODUCTION
PHP borrows a bit of its syntax from other languages such as C, shell, Perl,
and even Java. It is really a hybrid language, taking the best features from
other languages and creating an easy-to-use and powerful scripting language.
When you finish reading this chapter, you will have learned
The basic language structure of PHP
How PHP is embedded in HTML
How to write comments
Managing variables and basic data types
Defining constants for simple values
The most common control structures, most of which are available in
other programming languages
Built-in or user-defined functions
If you are an experienced PHP 4 developer, you might want to skip to the
next chapter, which covers object-oriented support of the language that has
changed significantly in PHP 5. (more…)


• • •
 

Abstract classes
A class may be declared abstract to prevent it from being instantiated.
However, you may inherit from an abstract class:
abstract class MyBaseClass {
function display() {
print “Default display routine being called”;
}
}
Abstract methods.
A method may be declared abstract, thereby deferring its definition to an
inheriting class. A class that includes abstract methods must be declared
abstract:
abstract class MyBaseClass {
abstract function display();
}
Class type hints.
Function declarations may include class type hints for their parameters.
If the functions are called with an incorrect class type, an error occurs:
function expectsMyClass(MyClass $obj) {
}
Support for dereferencing objects that are returned from methods.
In PHP 4, you could not directly dereference objects that were returned
from methods. You had to first assign the object to a dummy variable and
then dereference it.
PHP 4:
$dummy = $obj->method();
$dummy->method2();
PHP 5:
$obj->method()->method2();
Iterators.
PHP 5 allows both PHP classes and PHP extension classes to implement
an Iterator interface. After you implement this interface, you can iterate
instances of the class by using the foreach() language
construct:
$obj = new MyIteratorImplementation();
foreach ($obj as $value) {
print “$value”;
}

(more…)


• • •
 

What Is New in PHP 5?
“The best way to be ready for the future is to invent it.”– John Sculley
1.1 INTRODUCTION
Only time will tell if the PHP 5 release will be as successful as its two prede-
cessors (PHP 3 and PHP 4). The new features and changes aim to rid PHP of
any weaknesses it may have had and make sure that it stays in the lead as the
world’s best web-scripting language.
This book details PHP 5 and its new features. However, if you are familiar
with PHP 4 and are eager to know what is new in PHP 5, this chapter is for you.
When you finish reading this chapter, you will have learned
The new language features
News concerning PHP extensions
Other noteworthy changes to PHP’s latest version

(more…)


• • •
 



captcha PHP Script Free PHP captcha script free php
Website Design by WebWalas.com