PHP Tutorial Part One: Getting Started with PHP

0
kambohg kambohg is offline Offline | Jun 3rd, 2009
can u clear own concept and can u make own logic in php this will b best thing for us i think basic is importent ok watting make own 1st logic then teach php plz
 
0
sameeraict sameeraict is offline Offline | Jun 5th, 2009
i m a begginer of php and i like the way this tutorial presents the lesson.it gives more details at the biggining , its very interesting.i like that.
 
0
jueric jueric is offline Offline | Jul 6th, 2009
Am very glad with the begginners tutorial with the php program..am really looking forward to part two of it.its surely interactive..if possible can i be sent the tutorial in my mail?
 
0
sameeraict sameeraict is offline Offline | Jul 7th, 2009
ok,i have some downloaded php tutorials i 'll send u them.
 
0
guru12 guru12 is offline Offline | Sep 15th, 2009
Hello All
Well.Great Post , Thanks a lot , it is very much elaborated and all can easily follow up your tips.
Thank you for your posting
 
0
asivksoft asivksoft is offline Offline | Sep 21st, 2009
Originally Posted by khess View Post
Programming in PHP is fun and easy. It is a very powerful scripting language that takes simple HTML and turns it into a fully-interactive experience for the web user. Let's get started!

Note: These tutorials assume that you have a working web server that's capable of displaying PHP code and that you have PHP installed on that web server system or that you're using a server that is equipped and ready.
You can run PHP on Windows. You can even use PHP with IIS (The Windows Web Server) so you don't necessarily need Unix/Linux and Apache.

PHP Reference

Your best reference for all things PHP is the PHP web site: www.php.net. Go there and bookmark it--you'll refer to it often.

PHP Speaks HTML

The first thing you have to learn and always remember is that if you use even one line of PHP code in an HTML file, you must name the file with a .php extension. The .php extension tells the web server that this file is special and needs special handling by the PHP executable and related libraries.

Delimit Your PHP

Second, all PHP functions and code must be inserted between the following delimiters
  1. <? php code ?>
--the less than question mark opens the code and the question mark greater than close. You must always use delimiters in pairs--an opening delimiter and closing delimiter. Delimiters are symbols that tell the web server what kind of content follows and how it should be handled. HTML uses delimiters too
  1. <TAG>
.

Example 1: How About a Date?

If you want to add the current date to a web page, the code would look like:

  1. <HTML><BODY>
  2. <? echo date("M-d-Y"); ?>
  3. </BODY></HTML>

Explanation: The 'echo' command tells the PHP program to echo the results that follow to the screen. Since you're using HTML and the browser is your "screen", that's where you see the results. The date function is a built-in PHP program that display the date in the format you specify in the parentheses.

Save the file with the filename, test.php.

Open the file by pointing your browser to the file on the webserver and you should see:

Jan-19-2009 (you'll see the current date)

Try changing the date format by moving things around ("d-M-Y") or just using one of the date variables ("Y"). Refer to the PHP documentation to get a full range of date variables. It's fun and useful.

The full list of PHP date-related functions are here.

Example 2: Who's Looking at You, Kid?

If you want to gather some info about the people that are looking at your site or if you just want to let them know you're watching, you can easily echo some of their information back to them by using what's known as Server Variables.

Note: This is not personal information, nor are you stealing anything from them. It is information that is transferred to your website when a visitor connects to your webpages.

You can get their IP Address and their Browser and Computer information. The IP Address is how computers communicate with each other on the Internet--think of it as kind of like a phone number or home address.

To see this information, edit your test.php file again and enter the following:

  1. <HTML><BODY>
  2. <? echo date("M-d-Y");
  3. echo "<P>";
  4. echo "Your IP Address is " . $_SERVER['REMOTE_ADDR'];
  5. ?>
  6. </BODY></HTML>

Explanation: The line
  1. echo "<P>";
is HTML for start a new Paragraph. The next line,
  1. echo "Your IP Address is " . $_SERVER['REMOTE_ADDR'];
sends the text, "Your IP Address is " to your browser. The dot (.) is PHP for concatenate or connect these two things. $SERVER['REMOTE_ADDR'] is a built-in Server variable that echoes the viewing browser's IP Address to their browser.

Save this file and point your browser to test.php.

You should see:

Jan-19-2009 (Current Date)

Your IP Address is 10.0.1.200 (The IP Address of Your Computer)

There are several variables from which to choose here. The complete list is located at: PHP_SERVER.

Change the Server variable or add new ones. For starters, try: HTTP_USER_AGENT to see your browser and computer information.

Stay tuned for PHP Tutorial Part Two: Combining HTML and PHP where you'll get a taste of how to integrate these two languages in a more elegant fashion. Don't worry, it's easy and you'll like the way it works. It's easier to read and more fun to write.
insert the paragraph
 
0
asivksoft asivksoft is offline Offline | Sep 21st, 2009
about IF condition
 
0
chowdary51 chowdary51 is offline Offline | 9 Days Ago
nice tutorial
 
 

Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC