Showing posts with label edit php. Show all posts
Showing posts with label edit php. Show all posts

Saturday, December 8, 2012

Introduction To Advanced PHP - Read Before Lesson 6

You Made It Past The Basics - Congratulations!
Please read over lessons 1-5 before starting this section.
By Stephon Unomon

 

       By now, you’ve got enough PHP knowledge under your belt to add basic PHP functionality in all of your websites. It’s pretty cool knowing things that a lot of others don’t know, and they’ll never be able to find out just by doing a “View Source” on your website (especially since you cant actually SEE PHP code by viewing the source in a browser!)

 

       In this section we are going to cover some more advanced PHP code. Things that you might not use just yet but once you are comfortable with PHP and want to get more out of it, you’ll be ready, my young apprentice.

 

       Quick tangent...before we get started here you are going to want to be able to place comments in your code. Why? It’s a heck of a lot easier to know why you wrote a specific line of code if you add comments...so you don’t come back in 3 months and ask yourself, “Was I drunk when I wrote this code??” Here are some examples of comment codes:

 

<?php

// This is a single comment line

# This is also a single comment line

/* This is a block comment, useful if you are working with a multi-line comment or are writing a story on your page that you don’t want people to see */

?>

You don’t have to use semicolons after each line, since the PHP server ignores comments because they aren’t actually commands. Now, on to more CODE! (ta-daaaa!)
 

PHP Strings - PHP Lesson 2

PHP Strings
By Stephon Unomon

 

In PHP, as a general rule, a String is any line of text contained within quotation marks. You can use either double quotation marks (“) or single quotation marks also known as apostrophes (‘) in a string. Strings could be considered the building blocks of PHP, considering most all data is going to come from what’s in a string.

 

<?php

$double = "quotation marks.";

$single = 'single quotes.';

?>

When using single quotes, you need to “escape” the apostrophe with the slash (just like you would with double quotation marks) if you wish to display it in the output text...

 

<?php

echo 'Wouldn\'t you like a bagel?';

?>

Special commands within strings...

 

There are some “secret commands” you can use within strings to manipulate the output text:

\n:  makes a new line

\r:  a carriage return

\t:  a tab
 
\$:  shows a dollar sign - remember PHP will be looking for a variable if you want to display a dollar sign and don’t use a slash...and throw an ugly error!

Kool PHP Suite - PHP User Interface Tools & Components