0_CodeSchool-TryPHP

August 7, 2017 | Author: Alberto Y.C | Category: Html, Php, Data Type, Array Data Structure, Boolean Data Type
Share Embed Donate


Short Description

Introduccion PHP...

Description

Level 1

Getting Started The Basics of PHP

What Will This Course Cover? Here’s what we’ll go over in this course.

Level 1

Syntax Basics & Variables

Level 2 Simple Arrays & Associative Arrays Level 3 Operators & Comparison Statements Level 4

Looping Constructs

What Do You Need to Know? Suggested prerequisites:

Basic HTML & CSS Front-end Foundations & Front-end Formations

Why PHP, Why Now? PHP is a server-side scripting language that has been around since 1997 and has grown into a modern and performant tool for building websites and applications.

Allows execution of code inline with our HTML markup Simple reading and processing of files and images Request and response processing with forms High performance, scales easily Let’s get started!

Starting From Scratch Example of a simple HTML file: index.html

Hello World

HTML

Output

Hello World

Renaming Our File Let’s change the file from .html to .php so it can be processed by the server. index.php

Hello World PHP files can render HTML as well as PHP!

PHP

Output

Hello World

What Is Different Now? Web Browser

Web Server Look for any PHP code

Request URL validation

Execute code

processing rendering

Render generated output Receive HTML & assets

Creating a Code Block index.php

PHP

PHP code is written

between these symbols

Let’s write some code that will output something so we can see it here!

Output

Our First PHP Code index.php

PHP

PHP statements end in semicolons echo outputs whatever comes after it

Output

Hello World

Variables and Data Subject to Change index.php

PHP

Variables in PHP always start with a $

Notice that the data in the variable isn’t printed out automatically

Output

Outputting Data That’s Stored in Variables index.php

Echoing the variable outputs the data inside of it

PHP

Output

Hoba

Variable Naming Conventions Variables must always begin with a $ followed by a letter.

$name

$10_best_targets

$_age

$so-very-invalid

$full_name

stalemate

$war_1984

PHP Code Can Go Anywhere index.php

Use the variable

PHP

Assign the variable Output

Hoba

Variables Can Be Used in Multiple Locations index.php

Output Same variable used twice

PHP

Hoba

What Have We Learned? Let’s have a quick review. •

Syntax basics



Code blocks



PHP request and response server workflow



Variables and naming rules



The echo statement

Now we can move on to some challenges!

Level 1

Getting Started Strings & Data

Our Code So Far index.php



PHP

Combining More Data With Variables index.php

PHP

Output Meteor Name: Hoba Notice the space?

The dot means “combine these two things”

String Evaluation index.php

PHP

Variables will print inside strings as long as you wrap them in double quotes

Output

Meteor Name: Hoba

PHP Data Types: Strings To define a string, we will surround our information in single quotes during assignment.

If you echo a false boolean, nothing will appear

Output

epic 600 Million Grams 1920 720 8.9 -19.5833333333 1

What Have We Learned? Let’s have a quick review. •

String concatenation



Strings



Integers



Floating point numbers or floats



Booleans

Level 2

Arrays Simple & Associative Arrays

Why an Array? Variables alone will not scale. We need a better way to keep our data. index.php

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF