Top Banner
INTRODUCTION TO PHP SDPHP Twitter: @sdphp | www.sdphp.org (coming soon) MeetUp: www.meetup.com/SanDiegoPHP/
49

Introduction to PHP - SDPHP

May 13, 2015

Download

Technology

Eric Johnson

Introduction to PHP.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to PHP - SDPHP

INTRODUCTION TO PHP

SDPHPTwitter: @sdphp | www.sdphp.org (coming soon)

MeetUp: www.meetup.com/SanDiegoPHP/

Page 2: Introduction to PHP - SDPHP

Who we are:Presenters

John Congdon - Senior Web Developer at Networx Online

Twitter: @johncongdon

Email: [email protected]

LinkedIn: http://www.linkedin.com/in/johncongdon

Eric Van Johnson - Systems Architect at AMCO International Education Services, Inc.

Twitter: @shocm

Email: [email protected]

LinkedIn: http://www.linkedin.com/in/vanjohnson

San Diego PHP User Group

San Diego PHP Meetups => http://www.meetup.com/SanDiegoPHP/

Facebook => https://www.facebook.com/groups/SanDiegoPUG/

IRC => freenode.net #sdphp

Twitter => @sdphp

Page 3: Introduction to PHP - SDPHP

A quick history

Created in 1994 by Rasmus Lerdorf and was a set of simple Common Gateway Interface (CGI) binaries written in the C programming language that he used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools"

In 1998 PHP 3.0 is announced and is a complete rewrite of the platform. By this time Andi Gutmans and Zeev Suraski of Tel Aviv, Israel join Rasmus to collaborate on the new implementation. This is also when PHP got it's official name PHP: Hypertext Preprocessor, which is a recursive acronym.

Page 4: Introduction to PHP - SDPHP

A quick history (cont.)

PHP 4 is released in 2000 sporting a new engine dubbed 'Zend Engine' (comprised of the first names of Zeev and Andi). PHP 4.0 introduces a wide range of additional new features. In addition to the highly improved performance it also included key features such as support for many more web servers, HTTP sessions, output buffering, more secure ways of handling user input and several new language constructs.

There are companies that still use PHP 4.x in their production environment. (And we like to make fun of them)

PHP 5 released in 2004 powered by Zend Engine II with a new object mode. Current stable version of PHP is 5.4.8. Several new features come packed in the current releases of PHP such as Namespace support, Native JSON support, and security improvements.

Page 5: Introduction to PHP - SDPHP

Who uses PHP?

EVERYONE!

Google / Yahoo / Facebook / Sony / Bank of America / NYSE / AT&T /

Blah Blah Blah Blah

Page 6: Introduction to PHP - SDPHP

OPEN & CLOSING TAGS

Page 7: Introduction to PHP - SDPHP

VARIABLES

A Variable, as the name suggests, can have its value change during the execution of a script.

Page 8: Introduction to PHP - SDPHP

CONSTANTS

A constant, once defined, cannot be changed or unset. Traditionally constants are uppercase.

Page 9: Introduction to PHP - SDPHP

INCLUDE FILE.. ONCE

Useful for class and function loading

Page 10: Introduction to PHP - SDPHP

INCLUDING MISSING SCRIPTS

Page 11: Introduction to PHP - SDPHP

TYPES IN PHP

• Strings

• Integers

• Floats

• Arrays

• and many more...

Page 12: Introduction to PHP - SDPHP

STRINGS

What's the difference?

Page 13: Introduction to PHP - SDPHP

INTEGERS

Page 14: Introduction to PHP - SDPHP

ARRAYS

Arrays are zero-based.

Arrays can be of mixed types

Page 15: Introduction to PHP - SDPHP

ASSOCIATIVE ARRAYS

Key => Value pairs of data

Page 16: Introduction to PHP - SDPHP

FLOW CONTROL

Page 17: Introduction to PHP - SDPHP

FOR LOOPS

Page 18: Introduction to PHP - SDPHP

FOREACH LOOPS

Page 19: Introduction to PHP - SDPHP

FOREACH LOOPS

Page 20: Introduction to PHP - SDPHP

WHILE LOOPS

Page 21: Introduction to PHP - SDPHP

DO WHILE

Page 22: Introduction to PHP - SDPHP

SWITCH CASES

Page 23: Introduction to PHP - SDPHP

CONTINUE AND BREAK

• for• foreach• while• do ... while• switch

Page 24: Introduction to PHP - SDPHP

ALTERNATE SYNTAXES

Page 25: Introduction to PHP - SDPHP

ALTERNATE SYNTAX: IF

Page 26: Introduction to PHP - SDPHP

ALTERNATE SYNTAX: FOR

Page 27: Introduction to PHP - SDPHP

ALTERNATE SYNTAX: FOREACH

ALTERNATE SYNTAX: WHILE

Page 28: Introduction to PHP - SDPHP

FUNCTIONS

Page 29: Introduction to PHP - SDPHP

CLASSES

Page 30: Introduction to PHP - SDPHP

MAGIC: GET

Page 31: Introduction to PHP - SDPHP

MAGIC: GET

Page 32: Introduction to PHP - SDPHP

MAGIC: SET

Page 33: Introduction to PHP - SDPHP

STATIC

Page 34: Introduction to PHP - SDPHP

CLASS CONSTANTS

Page 35: Introduction to PHP - SDPHP

CLASS VISIBILITY

Page 36: Introduction to PHP - SDPHP

METHOD OVERLOADING

Page 37: Introduction to PHP - SDPHP

DATABASE ACCESS

Why you should be using PDO (PHP Data Objects)

• Cross Database Driver support

• Prepared Statements

• Proper bindings

• and lots lots more

Page 38: Introduction to PHP - SDPHP

MODELS, VIEWS, CONTROLLERS

• Code Separation

• Reusability

• Ease Refactoring

Page 39: Introduction to PHP - SDPHP

MODELS

• a model represents your data

• Logical container foro Database callso API Access

• Models usually represento Tables in a databaseo a file or collection of files on a hard driveo Documents stored in Mongoo Any other data containers you need to define

Page 40: Introduction to PHP - SDPHP

VIEWS

Page 41: Introduction to PHP - SDPHP

VIEW.. MODELS?

Page 42: Introduction to PHP - SDPHP

CONTROLLERS

Page 43: Introduction to PHP - SDPHP

Other cool things PHP can do that not a lot of people know.

• PHP CLI - PHP files don't have to be web pages. PHP is a very powerful language that can be used from the command line to perform a wide range of system task.

• As of PHP 5.4.0, the CLI SAPI provides a built-in web server. $ cd ~/public_html

$ php -S localhost:8000

Page 44: Introduction to PHP - SDPHP

More other cool things

• As of PHP 5.1.0, the CLI SAPI provides an interactive shell using the -a option.

Page 45: Introduction to PHP - SDPHP

PHP Tools

• Text Editor (Notepad / Notepad ++)

• Vim

IDEs

• Eclipse (Open Source)o PDT Plugin (Open Source)o Aptana PHP (Open Source)

Aptana Studio Pro (Commercial)o Zend Studio (Commercial)

• NetBeans (Open Source)

• PhpStorm (Commercial)

• NuSphere PhpED (Commercial)

Page 46: Introduction to PHP - SDPHP

What do employers look for?

• A college degree, so you are on the right track

• Code examples. Will typically check for a Github account. Make sure you have some publicly contributed code. Open Source Projects are good place to do this.

• Certificationso Zend PHP Certifications http://www.zend.com/services/certification/o MySQL Developer http://education.oracle.com/pls/web_prod-plq-

dad/db_pages.getpage?page_id=458&get_params=p_track_id:MDEV

Page 47: Introduction to PHP - SDPHP

What else do employers look for?

PASSIONDevelopment is a very personal thing.

A developer needs to be creative, logical, focused, and enjoy what they are doing. Get involved with the PHP community. Forums, StackOverflow, Local User Groups like SDPHP ;-)

Page 48: Introduction to PHP - SDPHP

Resources

Local

San Diego PHP Meetups => http://www.meetup.com/SanDiegoPHP/

Facebook => https://www.facebook.com/groups/SanDiegoPUG/

IRC => freenode.net #sdphp

Twitter => @sdphp / @shocm / @johncongdon / @williammanley

Others

Zend.com

StackOverflow => http://stackoverflow.com/questions/tagged/php

php|Arch => http://www.phparch.com/

Page 49: Introduction to PHP - SDPHP

CreditsOriginal Presentation by

William Cahill-Manley - Application Developer for Submodal

Twitter: @williammanley

Email: [email protected]

Today's Presenters

John Congdon - Senior Web Developer at Networx Online

Twitter: @johncongdon

Email: [email protected]

LinkedIn: http://www.linkedin.com/in/johncongdon

Eric Van Johnson - Systems Architect at AMCO International Education Services, Inc.

Twitter: @shocm

Email: [email protected]

LinkedIn: http://www.linkedin.com/in/vanjohnson