Results 1 to 25 of 93
Thread: Basics Of PHP
-
11-12-2005, 09:43 PM #1Newbie
- Join Date
- Nov 2005
- Posts
- 24
Basics Of PHP
I figured it's time to make a small tutorial , by reading this tutorial you should have the basic know how to execute small script's on your php enabled servers. Note that i will not be explaining how to set up a web server + php.
What Does PHP Stand For?
PHP- Hypertext Preprocessor
Starting & Ending Tags
We start off by learning the 2 main tag's that you must never forget , that is the starting and ending tag's.
StartingCode:<?php
Code:?>
Now that you know about the starting & ending tag's , let's start with a basic script.
Code:<?php echo "This is my first php script!"; ?>
Variables
Now that you know some basic syntax let's start working on variables , variables are ton's of fun and one of the most important part's of PHP.
Code:<?php $myfirstscript = "This is my first php script!"; echo $myfirstscript; ?>
Comments
Comments are also another important thing not only in php but all languages , there used to disable any type of information inside them from actually executing with your script which ofcourse would likely cause error's.
Code://This is a comment /*This is a comment block*/
Now these are fun to play with , they are used to execute certain code on a condition.
Code:<?php $mybrowser = "Fire Fox"; if ($mybrowser == "Fire Fox") { echo " You are using firefox!"; } else { echo " You are not using firefox"; } ?>
Looping
Looping is used for many many thing's , there are more then just one loop statement, ill explain how to do the "While Loop".
Code:<?php $z = 1; while ($z <= 5) { echo $z; $z++ }
Code:while ($z <= 5)
Code:echo $z
Code:$z++
Forms
Now im assuming you have some basic understanding of html, although i will give an example of the html form but i will not be explaining it.
Code:<form action="form.php" method="post"> Name: <input type="text" name="name"> <input type="submit" value="Submit">
Code:<?php $name = $_POST["name"]; echo "Hello ". $name; ?>
Now this is the end of this small basic tutorial , you should now have the knowledge to execute simple script's on your server's.
-
05-29-2006, 02:56 AM #2Newbie
- Join Date
- May 2006
- Posts
- 11
I would suggest editing $mybrowser = "Fire Fox"; to something less browser related. There are actually people out there who might think this code determines what browser is being used!
-
05-29-2006, 03:48 AM #3Web Hosting Master
- Join Date
- May 2002
- Location
- NE USA (Almost Canada)
- Posts
- 993
Just An Extra Note:
If you would like to get the PHP information from your site:
With a plain text editor paste this in:
Code:<?php phpinfo() ?>
Figured that'd be good for folks who are just starting on the basics and if it's covered anywhere here already I'm not really sure.
KGIIIWhat Hosting Should Be
A Blog as CMS, eBay, PR, and Ads?
My personal email: KGIII <at> KGIII <dot> INFO
Microsoft MVP 2003/2006 Categories: Shell/User and Internet Explorer (Gł Solutions)
-
09-16-2006, 03:10 PM #4Newbie
- Join Date
- Sep 2006
- Posts
- 12
nice one, ive already learnt this but i havent used php in a while so its nice to refresh my memory abit, great post for people who want to get into php
-
09-17-2006, 07:38 AM #5Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 1,767
Actually for a phpinfo() I would do this, since it volunteers a lot of information about your server, that you may not neccessarily want being public.
PHP Code:<?PHP
$ip = getenv("REMOTE_ADDR");
$allowed_ip = "24.211.80.102"; // change to your ip
if ($ip == $allowed_ip) {
phpinfo();
} else {
header("Location: /");
}
?>
-
10-24-2006, 10:18 PM #6Web Hosting Master
- Join Date
- Feb 2006
- Location
- Buffalo, NY
- Posts
- 1,501
Or just create the file when needed / don't name it phpinfo.php
(Or just add a constant to the index.php to show phpinfo if defined, etc)█ Cody R.
█ Hawk Host Inc. Proudly Serving websites since 2004.
█ Official Let's Encrypt Sponsor
-
10-25-2006, 01:01 AM #7New Member
- Join Date
- Oct 2006
- Posts
- 4
Is there a function in PHP that's similar to CFHTTP? I need to read the contents of one of our sites.
-
10-25-2006, 01:03 AM #8New Member
- Join Date
- Oct 2006
- Posts
- 4
Is it better to use $_request instead of $_POST or $_GET? Since it does what $_POST and $_GET do anyway. Is there a drawback to using it?
-
10-25-2006, 01:45 AM #9Web Hosting Master
- Join Date
- Feb 2003
- Location
- AR
- Posts
- 2,382
If your form is ONLY using the post method, use $_POST. Likewise for $_GET. If your form should accept both methods, use $_REQUEST.
Kevin
-
11-14-2006, 04:09 AM #10Newbie
- Join Date
- Jun 2006
- Location
- California
- Posts
- 8
Good short, tutorial, good for new people wanting to learn PHP.
Next thing functions, classes and arrays!
-
12-29-2006, 02:20 PM #11Web Hosting Master
- Join Date
- Mar 2006
- Posts
- 984
Nice block from SNC. However, I'd state this line:
PHP Code:$ip = getenv("REMOTE_ADDR");
PHP Code:$ip = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : getenv("REMOTE_ADDR");
-
12-31-2006, 03:54 PM #12Junior Guru Wannabe
- Join Date
- Dec 2006
- Location
- PA
- Posts
- 99
thank u so much this is nice short tutorial
-
01-07-2007, 02:19 AM #13Newbie
- Join Date
- Oct 2005
- Posts
- 9
Nicely put togethor, well done
-
01-21-2007, 03:44 PM #14Newbie
- Join Date
- Jan 2007
- Posts
- 11
Anyone seriously looking to learn PHP should bookmark the site below. If you have any questions they can usually be answered there.
http://www.php.net/
The function reference is particularly useful.
http://www.php.net/manual/en/funcref.php
-
01-21-2007, 03:46 PM #15Big fan of RajiniKanth!!!
- Join Date
- Sep 2004
- Location
- Chennai , India
- Posts
- 4,632
Originally Posted by vkess
-
02-13-2007, 10:34 PM #16Newbie
- Join Date
- Sep 2006
- Posts
- 5
Hi, I'm PHP beginner. Could you advice me any free PHP engine for my site?
Thank you
-
02-14-2007, 12:04 AM #17Web Hosting Master
- Join Date
- Mar 2006
- Posts
- 984
PHP engines are mostly programmed for specific concepts. What kind of PHP engine are you looking for actually ?
-
02-17-2007, 12:23 PM #18Newbie
- Join Date
- Feb 2007
- Posts
- 14
OpenSourceCMS has a lot of free scripts, try looking there
so does resourceindex.com
-
02-22-2007, 07:43 PM #19Web Hosting Master
- Join Date
- Mar 2006
- Posts
- 984
I received an email notification regarding a new post on this topic ... not too sure how new it is . . . have I missed something ?
-
03-03-2007, 05:57 PM #20Web Hosting Master
- Join Date
- Mar 2006
- Posts
- 984
Yeah, it pretty much looked like this one:
PHP Code:hmmmmmmmmmmmm
-
07-30-2008, 05:39 AM #21Newbie
- Join Date
- Dec 2006
- Location
- New Zealand
- Posts
- 16
Thanks, I really want to learn PHP but my head just won't get around it haha.
-
08-12-2008, 06:49 AM #22New Member
- Join Date
- Aug 2008
- Posts
- 2
Nice Tutorial , good for teh beginers
-
08-22-2008, 05:27 PM #23Junior Guru Wannabe
- Join Date
- Aug 2008
- Posts
- 76
Besides knowing what it is, I really don't know where to really start for learning PHP. I have a fair outline of HTML and grasp the basics of CSS (I only know how to work with Dreamweaver). How did you guys learn PHP? Any recommended book?
-
09-13-2008, 04:23 PM #24Newbie
- Join Date
- Apr 2005
- Posts
- 12
Well, nice tutorial for the beginners who are just starting to wet their feet with php. After going through this basic quickie, they must go on to learn further through other resources available on the net.
-
09-16-2008, 11:57 PM #25New Member
- Join Date
- Sep 2008
- Posts
- 1
thanks for the info