View Single Post
  #4 (permalink)  
Old 03-10-2009, 10:33 AM
grace55 grace55 is offline
Administrator
Site Admin
 
Join Date: Jun 2008
Posts: 342
Default A journey leads to php....

Now, Let’s Code!

We’re going to tackle the basics to start with. Getting PHP to write things to the web browser, what variables are and how to use them...examples you can use in just about every web page you create.

Let’s start with the most basic one.

The PHP Echo command

We’re going to tell PHP to output something to the screen. Keep in mind that PHP can be used in conjunction with HTML, but we are not showing the code in this example, to keep it simple:

<?php echo “Creamy Bagels”; ?>

Let’s dissect the command example bit by bit, shall we? It helps to do this when you are looking at a LOT of PHP code...because, trust me, it can look like a jumbled blurry mess sometimes if you don’t take it piece by piece! So next time, please, if you will...

<?php - tells the server to process this as php code...

echo “Creamy Bagels” ; - tells the server to write what’s in the quotes to the screen, and that the semicolon is ending this particular command...

?> - tells the webserver, “OK, I’m done with PHP for now. Back to regular HTML”.

Pretty simple when you look at it that way, yes?

OK, that’s cool..but what if I want to see quotes on my screen?” Want to know ? Wait....

This can be done by “escaping” the PHP code for what you want to show up in quotes. Let’s use the example from above...

<?php echo “Creamy Bagels”; ?>

If you wanted to see quotes around Creamy Bagels, you would use the following code instead:

<?php echo “\”Creamy Bagels\””; ?>

Using \” tells PHP that you want a quotation mark to appear. Remember this - we’re going to use it later!
__________________
Christian Prayer Forum
Reply With Quote