Eternal Nightmare
March 29, 2024, 08:18:46 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Breaking News: We Are Growing Fast. Keep Up The Good Work Guys
 
  Home Help Search Arcade Staff List Login Register  

PHP Basics

Pages: [1] 2
  Print  
Author Topic: PHP Basics  (Read 1132 times)
0 Members and 1 Guest are viewing this topic.
DzinestaR
Starter
*

OWned +0/-0
Offline Offline

My Mood: Inspired:
Posts: 18



WWW
« on: September 13, 2009, 03:03:08 pm »

The greatest thing about PHP is the fact that it's a web-specific language.  The language is specifically intended to be used for internet development which means you get many features which makes it easier for you to work with the language on the internet.  One of the greatest things about PHP is how you can mix and match PHP code with HTML code.

If you're familiar with HTML, you know what all HTML tags (special words that format an HTML webpage) are encased in <s and >s.  For example, to bold a string, you would sandwich it between the <b> and </b> tags.  PHP doesn't quite work this way.  Instead, all PHP code goes right inside a huge single tag - the PHP tag.

The PHP tag can look one of two standard ways (there are other alternatives which are rarely used):
<?php ?> - the long version of the tag
or
<? ?> - the short version of the tag

Anything inside these tags will be recognized as PHP code, anything outside these PHP tags will be recognized as plain HTML.  A simple example is the following (again, you don't need to know exactly what the following does right now).  Save the following file into your "www" directory and run it by going to "http://127.0.0.1/basic.php".

basic.php
Code:
<html>
<head>
<title></title>
</head>
<body>

<? print 'php code here'; ?>

</body>
</html>

Some people don't like this method and will instead encase the entire file's contents inside PHP tags and use functions inside the PHP language to output their HTML code.

The other basic thing I want to cover in this lesson is how to "comment" in PHP.  A comment is a way for you to insert explanations of code in plain English which will in NO way affect your program.  Comments help other programmers understand code you've written.  Comments can be written in several ways (save and test the following file):

comments.php
Code:
<?
print 'hello<br>'; //this is a comment, this line prints "hello"

print 'how are you?<br>'; #this is also a comment, this line prints "how are you?"

print 'I am good thank you<br>'; /* this is a multi-line comment
                                    and can span several lines */
?>

Anything after "//" or "#" on a line is interpreted as a comment and will not be used.  Anything between the "/* */" characters will also be interpreted as comments.  Comments can be stuck anywhere in between lines of code or after code on a line, but not before except the "/* and */" comment because then all code after the comment will be interpreted as comments too.

For example:

Code:
<?
print 'hello<br>'; //this is a comment, this line prints "hello"
//here is another comment tag
print 'how are you?<br>'; #this is also a comment, this line prints "how are you?"
#more comments inbetween
/* a comment before with this type of comment tag */ print 'I am good thank you<br>';
/* this is a multi-line comment and can span several lines */
?>

« Last Edit: September 13, 2009, 03:10:07 pm by DzinestaR » Report Spam   Logged

Share on Facebook Share on Twitter

xboi209
Newbie
*

OWned +0/-0
Offline Offline

Gender: Male
Posts: 6


« Reply #1 on: September 17, 2009, 01:33:16 am »

cant you use echo instead of print?
Report Spam   Logged
Nick
Administrator
Devotee
*

OWned +28/-66
Offline Offline

Gender: Male
My Mood: Tired:
Posts: 729


Owner


WWW
« Reply #2 on: September 17, 2009, 07:49:27 am »

what echo??
Report Spam   Logged




DzinestaR
Starter
*

OWned +0/-0
Offline Offline

My Mood: Inspired:
Posts: 18



WWW
« Reply #3 on: September 23, 2009, 11:04:25 am »

cant you use echo instead of print?

Yes you can, but I will cover that in the next tutorial I write.
Report Spam   Logged

deadrok
Starter
*

OWned +0/-0
Offline Offline

Gender: Male
My Mood: Cool:
Posts: 22

Hi people!


« Reply #4 on: October 16, 2009, 07:22:02 am »

This is a nice guide, atleast it will help people with PHP problems.
Report Spam   Logged

*Nice to meet everyone!*

*This is a nice forum!*
xboi209
Newbie
*

OWned +0/-0
Offline Offline

Gender: Male
Posts: 6


« Reply #5 on: October 21, 2009, 12:40:06 am »

theres lots more to cover in php, this basic php tutorial only covered commenting and putting words on a webpage.
Report Spam   Logged
adam84
Newbie
*

OWned +0/-0
Offline Offline

Posts: 1


« Reply #6 on: April 30, 2010, 11:12:20 am »

It is a nice thing to learn..

________

HDMI Cable
USB Cable 
 
Report Spam   Logged
henderson791
Starter
*

OWned +0/-0
Offline Offline

Posts: 12


« Reply #7 on: May 03, 2010, 01:16:16 pm »

It is really a great tutorial. I am very much helpful from this.Thanks for your great help.
________________________________________________
Firewire Cable
Guitar Cable
Report Spam   Logged
svr2112
Starter
*

OWned +0/-0
Offline Offline

Posts: 29


« Reply #8 on: August 16, 2010, 06:20:16 am »

# PHP: Hypertext Preprocessor (the name is a recursive acronym) is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. ...
# The peso (Filipino: piso) (sign: ₱; code: PHP) is the currency of the Philippines. It is subdivided into 100 centavos (Spanish) or sentimo (Filipino). Before 1967, the language used on the banknotes and coins was English and so "peso" was the name used. ...
# A scripting language widely used to write web applications
# PHP (Hypertext Preprocessor) is a popular general-purpose server side scripting language which can be embedded into HTML to create a wide variety of mini-applications, but can also be used to build large-scale complex applications.
# PHP is the most popular language to create web sites. PHP is an interpreted language and is executed on server side (just like CGI or ASP scripts, ...) contrary to scripts executed on client side (a Javascript or a Java applet executes on your computer ...). ...
# PHP, or "PHP: Hypertext Preprocessor", is a commonly-used open-source scripting language. phpBB is written in PHP and requires the PHP runtime engine to be installed and properly configured on the server phpBB is run on. For more information about PHP, please see the PHP home page.

___________

Insurance | Accident Insurance
Report Spam   Logged
omar32733
Regular
*

OWned +0/-0
Offline Offline

Posts: 71


« Reply #9 on: August 31, 2010, 11:06:48 am »

Theres lots more to cover in php, this basic php tutorial only covered commenting and putting words on a webpage.
_____________________________
Cheap Flights
Compare Cheap Flights
Report Spam   Logged
ajohns229
Starter
*

OWned +0/-0
Offline Offline

Posts: 26


« Reply #10 on: November 03, 2010, 11:31:11 am »

Theres lots more to cover in php, this basic php tutorial only covered commenting and putting words on a webpage.
__________________________________
HDMI Cable
HDMI Cables
Report Spam   Logged
oral1139
Starter
*

OWned +0/-0
Offline Offline

Posts: 16


« Reply #11 on: January 19, 2011, 05:29:53 am »

It is really a great tutorial. I am very much helpful from this.Thanks for your great help.
_____________________________________
SEO UK
UK SEO
Report Spam   Logged
shandy7894
Starter
*

OWned +0/-0
Offline Offline

Posts: 44


« Reply #12 on: January 28, 2011, 04:42:12 am »

Yes you can, but I will cover that in the next tutorial I write.
________________________________
digital marketing agency
Report Spam   Logged
trenton2345
Enthusiast
*

OWned +0/-0
Offline Offline

Posts: 104


« Reply #13 on: April 13, 2011, 05:35:48 am »

Yes you can, but I will cover that in the next tutorial I write.
______________________
Roller Blinds
Blinds
Report Spam   Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy