PHP code can be formatted nice and wide with lots of space for easier readability and debugging. You can stuff it all on 1 or two lines and PHP can still interpret it... but in 6 months, when you need to update it... will you be able to?
all examples of PHP code will be formatted like this in white boxes w/ double letters to help you see... I omitted the <? ?>, but you'll see them in the nft examples
All pages with embedded PHP MUST be given the .PHP file extension so the server knows to expect PHP code. The server takes the pages, interprets all the PHP code, converting into the appropriate HTML (based on the PHP values) and then returns the page to the viewer (or "client").
Files containing PHP code must have a .PHP extension
All PHP code inside a page must enclosed with either a <? ?> or a <?PHP ?> (upper or lower-case "PHP" does not matter)
<? code goes here ?>
<?PHP code goes here ?>
Comments are good and useful!
// This is a single line comment, can be used at end of a line of code
/* This is a multiple line comment that can go on and on and on...
all stuff inside the slash-stars are ignored */
All PHP commands end in a ;
<? echo "string"; ?>
All variables begin with a $
$x = 1; // variable x is an integer assigned the value 1
$y = "This is a string"; //variable y is a string
$z = array(); //variable z is an array
PHP is not case sensitive, but the operating system you are using may be.
MySQL SQL statements are not case sensitive, but it is considered good practice to capitalize SQL Keywords.
MySQL database, tables, and column names ARE case sensitive.. so a table named "gfmembers" is NOT the same as a table named "GFMembeRS". It is a good idea to adopt a practice of of using letter case consistently due to this issue.
For portability between servers and operating systems, all database, table names, and column names must begin with a letter a-z.
Lesson Two - PHP in Fusion
Did you find this tutorial useful? Would like to view all of our tutorials and support pages?
Join the NetObjects Fusion Users Group Community