Mario's Domain Logo
change style to old
Change style to new
Mario's Domain - PHP Tutorial
I have been working with PHP only since the spring of 2007, and I wanted to put the things I have learned somewhere easy to access. So I decided to make a page that is really more of a notes page then a how to page. As I get deeper into using PHP I will turn this into an MSDN like page.
Credits: Larry Ullman author of PHP and MySQL for Dynamic Web Sites - ISBN: 0-321-33657-7
This is the book that I am learning PHP from, and I like it. I am picky about books too. The author writes in a way that is good for any level of programmer. I already know HTML, and have worked with JavaScript, but have never touched PHP, and I get along with this book easily. Most of the information here I learned from this book.

Syntax
All PHP code must appear between the tags below.




<?php

?>

Or another version.



<?

?>

Either one will work.

Printing to the Browser
In JavaScript you have the document.writeline to send the JavaScript output to the browser, but it is limited. In PHP it is a lot more versatile.




echo()
USE
echo "Text to show up in browser";
OR
print()
USE
print "Text to show up in browser";

Commenting
Single Line Comments




# Rest of line is commented out
OR
// Rest of line is commented out

Multi Line Comments



/* Everything from the start of this line

to the end of this line is commented out */

Variables
Scalar or Single Valued

  • Boolean - True or False
  • integer - whole number
  • floating point - decimal
  • strings - text

NonScalar - MulitValued
  • arrays
  • object

and...
NULL - no value
variable names....
  • are case-sensitive
  • must start with a $
  • can contain combinations of letters, numbers and the unserscore
  • first letter after $ must be a letter or underscore
  • are assigned vales by the =

Concatenation
Use the period [.] to combine, or concatenate two strings together




$string1= "Begin String"
$string2= "End String"

$string3= $string1 . $string2
NOW
$string3= "Begin StringEnd String"