Hello World! - Just testing out a little PHP - back to the basics


10


I love W3Schools.com!


9


A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function:

Variable x inside function is:

Variable x outside function is: 5




A variable declared within a function has a LOCAL SCOPE and can only be accessed within that function:

Variable x inside function is:

Variable x outside function is: 5




PHP The global Keyword
The global keyword is used to access a global variable from within a function.
To do this, use the global keyword before the variables (inside the function):

Variable x inside function is:

10


PHP The static Keyword
Normally, when a function is completed/executed, all of its variables are deleted.
However, sometimes we want a local variable NOT to be deleted. We need it for a further job.
To do this, use the static keyword when you first declare the variable:
0
1
2
3
4


PHP echo and print Statements
echo and print are more or less the same. They are both used to output data to the screen.
The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.

PHP is Fun!

Hello world!
I'm about to learn PHP!
This string was made with multiple parameters.

Learn PHP

Study PHP at W3Schools.com
9


PHP Data Types
Variables can store data of different types, and different data types can do different things.

(Examples where here: www.w3schools.com/php/php_datatypes.asp) PHP supports the following data types:
  • String - A string is a sequence of characters, like "Hello world!".
  • Integer - An integer is a whole number (without decimals). It is a number between -2,147,483,648 and +2,147,483,647.
  • Float (floating point numbers - also called double) - A float (floating point number) is a number with a decimal point or a number in exponential form.
  • Boolean - A Boolean represents two possible states: TRUE or FALSE. Booleans are often used in conditional testing.
  • Array - An array stores multiple values in one single variable.
  • Object - An object is a data type which stores data and information on how to process that data. In PHP, an object must be explicitly declared.
  • NULL - Null is a special data type which can have only one value: NULL. Variables can also be emptied by setting the value to NULL
  • Resource - The special resource type is not an actual data type. It is the storing of a reference to functions and resources external to PHP.
PHP Integer
An integer is a whole number (without decimals). It is a number between -2,147,483,648 and +2,147,483,647.

Rules for integers:
An integer must have at least one digit (0-9)
An integer cannot contain comma or blanks
An integer must not have a decimal point
An integer can be either positive or negative
Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0)
In the following example $x is an integer. The PHP var_dump() function returns the data type and value:
int(5985)

PHP Array
An array stores multiple values in one single variable.
In the following example $cars is an array. The PHP var_dump() function returns the data type and value:
array(3) { [0]=> string(5) "Volvo" [1]=> string(3) "BMW" [2]=> string(6) "Toyota" }


red
green
blue
yellow



The real power of PHP comes from its functions; it has more than 1000 built-in functions.
Function PHP

Hello world!

What is an Array?
An array is a special variable, which can hold more than one value at a time.




3


/index.php
231webdev.com
231webdev.com

CCBot/2.0 (http://commoncrawl.org/faq/)
/index.php





http://www.w3schools.com/php/php_date.asp - That is where I was when I stopped.

The time is 07:46:35am
The time is 06:46:35am




The time is 07:46:35am

(Muskegon, MI) Eastern Time Zone (UTC-05:00)

The time is 06:46:35am

(Chicago) Central Time Zone (UTC-06:00)


The time is 05:46:35am

(Denver) Mountain Time Zone (UTC-07:00)

The time is 04:46:35am

(West Coast) Pacific Time Zone (UTC-08:00)




Current Server Time:

Like 231WebDev on Facebook!

Acenet Web Hosting