learning php, lesson 1: an introduction to php
TRANSCRIPT
![Page 1: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/1.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 1/22
www.rorygilchrist.co.uk
Lesson 1:An Introduction to PHPRory Gilchrist
Monday, 6 December 2010
![Page 2: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/2.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 2/22
www.rorygilchrist.co.uk
An Introduction to PHP
✤ What is PHP?
✤ Page preprocessor
✤ Open source
✤ Application written in C
✤ Based on C syntax
✤ Uses .php file extension
✤
Created in 1995Monday, 6 December 2010
![Page 3: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/3.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 3/22
www.rorygilchrist.co.uk
What is a page preprocessor?
Monday, 6 December 2010
![Page 4: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/4.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 4/22
www.rorygilchrist.co.uk
What is a page preprocessor?
Monday, 6 December 2010
![Page 5: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/5.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 5/22
www.rorygilchrist.co.uk
What is a page preprocessor?
index.php
Monday, 6 December 2010
![Page 6: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/6.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 6/22
www.rorygilchrist.co.uk
What is a page preprocessor?
index.php index.php
Filesystem
Monday, 6 December 2010
![Page 7: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/7.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 7/22
www.rorygilchrist.co.uk
What is a page preprocessor?
index.php index.php
Filesystem
Monday, 6 December 2010
![Page 8: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/8.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 8/22
www.rorygilchrist.co.uk
What is a page preprocessor?
index.php
PHP
index.php
Filesystem
Monday, 6 December 2010
![Page 9: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/9.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 9/22
www.rorygilchrist.co.uk
What is a page preprocessor?
index.php
PHP
index.php
Filesystem
Monday, 6 December 2010
![Page 10: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/10.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 10/22
www.rorygilchrist.co.uk
What is a page preprocessor?
index.php
PHP
index.php
Filesystem
Monday, 6 December 2010
![Page 11: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/11.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 11/22
www.rorygilchrist.co.uk
Written in C
✤ Very widely used programming language
✤ Used to build operating systems and kernels
✤ Many adaptations (C++, C#, Objective-C, etc)
✤ PHP shares syntax with C
Monday, 6 December 2010
![Page 12: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/12.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 12/22
www.rorygilchrist.co.uk
Coding in PHP
✤ Must be enclosed in special PHP tags
<?php
//code goes here?>
✤ Code within tags will be processed by server
✤
PHP files can be hybrid (PHP embedded within HTML)✤ Files to be handled by PHP must have .php extension
Monday, 6 December 2010
![Page 13: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/13.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 13/22
www.rorygilchrist.co.uk
Structure
✤ PHP uses variables
✤ Has built in functions to assist with common tasks
✤ Support for user-made functions
✤ Version 5 onward has a full object-oriented approach
Monday, 6 December 2010
![Page 14: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/14.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 14/22
www.rorygilchrist.co.uk
Printing to the web page
✤ Preprocessing is done before page is returned to user
✤ Must have function to print output to web page
✤ Two basic functions for printing out to the web page
✤ echo
Monday, 6 December 2010
![Page 15: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/15.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 15/22
www.rorygilchrist.co.uk
First PHP application: hello world
✤ Our first application, hello world:
<?php
echo “Hello World”;
?>
✤
PHP output: Hello World
✤ PHP processes code in place
✤ Any echo statements will appear in place of the PHP code once
rocessedMonday, 6 December 2010
![Page 16: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/16.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 16/22
www.rorygilchrist.co.uk
Variables
Monday, 6 December 2010
![Page 17: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/17.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 17/22
www.rorygilchrist.co.uk
Variables
$name
Monday, 6 December 2010
![Page 18: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/18.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 18/22
www.rorygilchrist.co.uk
Variables
$name
Monday, 6 December 2010
![Page 19: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/19.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 19/22
www.rorygilchrist.co.uk
Variables
$name
<?php
$name = “Roger”;
echo $name;?>
PHP Output:
Roger
Monday, 6 December 2010
![Page 20: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/20.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 20/22
www.rorygilchrist.co.uk
Maths
✤ Mathematical engine
✤ Range of maths functions to aid complex programming
✤ Basic example:
<?php
$sum = 2 + 4;
echo $sum;
?>
PHP Output:
6Monday, 6 December 2010
![Page 21: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/21.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 21/22
www.rorygilchrist.co.uk
Lesson Notes: Syntax
✤ All PHP surrounded by <?php ?>
✤ <?php tag should NOT be preceded by whitespace
✤ Variables declared using $ and =
✤ All line endings must have ;
✤ Text strings should always be enclosed in “ “ or ‘ ’
✤ Commenting text out for documentation purposes done by either //Comment or /* Comment */
Monday, 6 December 2010
![Page 22: Learning PHP, Lesson 1: An introduction to PHP](https://reader033.vdocuments.site/reader033/viewer/2022052710/577d33dd1a28ab3a6b8bec86/html5/thumbnails/22.jpg)
8/8/2019 Learning PHP, Lesson 1: An introduction to PHP
http://slidepdf.com/reader/full/learning-php-lesson-1-an-introduction-to-php 22/22
www.rorygilchrist.co.uk
Questions
✤ If you have any questions about this lesson or would like me to goover anything with you, please get in touch: