• Complain

Christopher Cosentino - Advanced PHP for Web Professionals

Here you can read online Christopher Cosentino - Advanced PHP for Web Professionals full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2003, publisher: Prentice Hall Professional, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Christopher Cosentino Advanced PHP for Web Professionals
  • Book:
    Advanced PHP for Web Professionals
  • Author:
  • Publisher:
    Prentice Hall Professional
  • Genre:
  • Year:
    2003
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Advanced PHP for Web Professionals: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Advanced PHP for Web Professionals" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Take your PHP programming skills to the next level, with this hands-on, example-rich tutorial! In Advanced PHP for Web Professionals, best-selling PHP author Christopher Cosentino brings together dozens of powerful new techniques for building serious Web applications. Learn how to manage sessions more effectively, create better forms, develop custom error handlers, build database-independent Web applications with PEAR::DB, parse XML files, authenticate users via database query, build cross-platform client apps with PHP-GTK, and much more!

Christopher Cosentino: author's other books


Who wrote Advanced PHP for Web Professionals? Find out the surname, the name of the author of the book and a list of all author's works by series.

Advanced PHP for Web Professionals — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Advanced PHP for Web Professionals" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make

Chapter 1. PHP Review

In This Chapter

  • Overview

  • PHP Syntax

  • Variables

  • Operators

  • Arrays

  • If/Then Statements

  • Switch Statements

  • For Loops

  • Foreach Loops

  • While Loops

  • Do While Loops

  • User-Defined Functions

  • Object Oriented Programming with PHP

  • phpinfo()

  • Additional Resources


Picture 1

Overview

This book assumes that you have some experience with PHP. This book is not meant to be an introductory text on PHP programming but is instead a book on some of the more advanced uses for PHP that you won't find in many of the introductory books or tutorials on the Web.

Having said that, I am still providing here a brief introduction to PHP for those who may need a quick refresher or are already familiar with a similar language, such as PERL.


Picture 2

While Loops

While loops are another useful construct to loop through data. While loops continue to loop until the expression in the while loop evaluates to false. A common use of the while loop is to return the rows in an array from a result set. The while loop continues to execute until all of the rows have been returned from the result set:

while($row = mysql_fetch_array($result)) { // do something with the resulting row}

You can also use the continue command to skip over the current iteration of the loop, then continue. For example:

while($row = mysql_fetch_array($result)) { if($row['name'] ! = "Jet")) { continue; } else { // do something with the row}
Picture 3

Do While Loops

Do while loops are another useful loop construct. Do while loops work exactly the same as normal while loops, except that the script evaluates the while expression after the loop has completed, instead of before the loop executes, as in a normal while loop.

The important difference between a do while loop and a normal while loop is that a do while loop is always executed at least once. A normal while loop may not be executed at all, depending on the expression. The following do while loop is executed one time, printing out $i to the screen:

$i = 0; do { print $i;} while ($i>0);

Whereas the following is not executed at all:

$i = 0; while($i > 0) {print $i;}

Quite frankly, I never find much use for do while loops, but you may find an odd problem that requires it.


Picture 4

User-Defined Functions

In addition to PHP's built-in functions, you can create your own functions. Remember that if you want to use variables that exist outside of the function, then you must declare them as global variables or assign them as arguments to the function itself.

function check_age($age) { if ($age > 21) { return 1; } else { return 0; }}//usage:if(check_age($age)) { echo "You may enter!";} else { echo "Access Not Allowed!"; exit;}

The function would be called from within your script at the appropriate time, using the following syntax:

$age = 10; check_age($age);// prints "Access Not Allowed!" to the screen
Picture 5

Object Oriented Programming with PHP

PHP supports Object Oriented Programming (OOP) in the form of classes. Just like in other OOP languages, the classes can be extended for greater reuse of code.

To create an address entry class that contains a person's first and last name and phone number:

class address_book_entry { var $first; var $last; var $number; function set_name($first, $last) { $this->first = $first; $this->last = $last; } function set_number($number) { $this->number = $number; } function display_entry() { echo "
Name: " . $this->first . " " . $this->last; echo "
Number: " . $this->number; }}//Usage:$entry = &new address_book_entry;$entry->set_name("Jane","Smith");$entry->set_number("555-555-5555");$entry->display_entry();//displays:Name: Jane SmithNumber: 555-555-5555

Additionally, you can extend an existing class to create a new class that has the same functionality of the old class, plus any new functionality you add:

class address_book_entry2 extends address_book_entry { var $email;function set_email($email) { $this->email = $email; } function display_entry2() { echo "
Name: " . $this->first . " " . $this->last; echo "
Number: " . $this->number; echo "
Email: " . $this->email; }}//Usage:$entry = &new address_book_entry2;$entry->set_name("Jane","Smith");$entry->set_number("555-555-5555");$entry->set_email("jsmith@com.com");$entry->display_entry();//displays:Name: Jane SmithNumber: 555-555-5555Email: smith@com.com
Picture 6

phpinfo( )

phpinfo() is a very useful function that allows you to see what version of PHP is running on your Web server, as well as all of the specific settings that are enabled in that version.

Throughout this book, there are sections that ask you to verify your settings. One way to do this is to create a script that includes just the following:

phpinfo();?>

Upon execution of the script, the browser displays the current PHP settings. This function is especially useful if you are working on somebody else's server and are not quite sure of its capabilities.


Picture 7

Additional Resources

If you still need additional information on the basics of PHP, the following books from Prentice Hall provide material suitable for the utmost PHP beginner:

  • Core PHP Programming: Using PHP to Build Dynamic Web Sites (2nd Edition) by Leon Atkinson. ISBN 0130893986.

  • Essential PHP for Web Professionals by Christopher Cosentino. ISBN 0130889032.

    [1] Shameless plug for my own book, I know, but I've received a lot of email from nonprogrammers who said the book really helped!


Picture 8

PHP Syntax

PHP is a language that was designed to be easily embedded into HTML pages (although you don't have to do it that way). Most PHP pages have PHP code and HTML intermixed. When a Web server reads a PHP page, it is looking for two things to let it know it should start reading the page as PHP rather than HTML, the start and end PHP tags:


Variables

You can also easily intertwine small segments of PHP into HTML, such as when printing out the value of a variable:

Today's Date is = $date ?>.

The "=" syntax in the php, when followed by a variable, is used as shorthand for the echo() function.

You can include comments in your PHP scripts. Comments are ignored by the Web server, and any comments contained within the PHP code are not sent to a browser. There are three forms of comments:

  • # Used just like it is used in PERL; comments out the remainder of the line after the # symbol.

  • // Used just like it is in JavaScript; comments out the remainder of the line after the // symbols.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Advanced PHP for Web Professionals»

Look at similar books to Advanced PHP for Web Professionals. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Advanced PHP for Web Professionals»

Discussion, reviews of the book Advanced PHP for Web Professionals and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.