ashiezai 0 Report post Posted October 20, 2005 this is a really good start up guide for php noobie like me ... after reading this ... i have got some clue what php is about and i know i will try to learn php more in the future ... a pretty good guide for beginners Share this post Link to post Share on other sites
broflovski 0 Report post Posted October 21, 2005 This is WAY too long for me to sit back and read all this. Share this post Link to post Share on other sites
shadowdemon 0 Report post Posted October 25, 2005 If you think that is to long try reading books about it. I had one question. In the If or esle statement can you have more then one if likeIfIfElseI no that isnt the correct code but would it work to have more then one If Share this post Link to post Share on other sites
Spectre 0 Report post Posted October 26, 2005 Yes. You can have has many if statements contained within each other as you like. However, it may be easier simply to be more specific with the original condition. // Multiple If() statements:if( condition1 ) { if( condition2 ) { if( condition3 ) { if( condition4 ) { echo 'Something'; } } }}// A simpler way:if( condition1 && condition2 && condition3 && condition4 ) { echo 'Something';} I should get around to writing more on this some time - probably around mid November when everything else is wrapped up. Thanks to all those who have commented (both positive and negative constructive feedback is appreciated). Share this post Link to post Share on other sites
shadowdemon 0 Report post Posted October 26, 2005 Yes. You can have has many if statements contained within each other as you like. However, it may be easier simply to be more specific with the original condition. // Multiple If() statements:if( condition1 ) { if( condition2 ) { if( condition3 ) { if( condition4 ) { echo 'Something'; } } }}// A simpler way:if( condition1 && condition2 && condition3 && condition4 ) { echo 'Something';} I should get around to writing more on this some time - probably around mid November when everything else is wrapped up. Thanks to all those who have commented (both positive and negative constructive feedback is appreciated). 198375[/snapback] I mean like If condition one or If condition 2 or If condition 3 then something then else something Share this post Link to post Share on other sites
electriic ink 1 Report post Posted October 26, 2005 If condition OR condition2 etc is.... if (condition1 || condition2) { performThis(); // Sample function} else { performThisInstead(); // Sample function} And you can combine the two...if ((condition1 || condition2) && (condition3 || condition4)) { performThis(); // Sample function} else { performThisInstead(); // Sample function} Share this post Link to post Share on other sites
XRated 0 Report post Posted November 10, 2005 (edited) Notice from BuffaloHELP: Merged two topics for two different tutorial approach. Please search the forum before making a new topic. Im not sure if this is supose to go in the programming forum or here , this said "Tutorials" so ive decided here , if im wrong you may move it or delete it --------------------------------------------------------------------------------------------------------------------------- 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. Starting <?php Ending ?> Baisc Syntax Now that you know about the starting & ending tag's , let's start with a basic script. <?phpecho "This is my first php script!";?>so you have noticed echo , echo is simple, it output's the text "This is my first php script!" , now you must end this with a semicolon , why? the semicolon is a seperator and is used to distinguish one set of instructions from another. 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. <?php$myfirstscript = "This is my first php script!";echo $myfirstscript;?> So you have noticed $myfirstscript , i made the variable $myfirstscript that hold's the string "This is my first php script!" . Then ofcourse just echo'd the variable which would output "This is my first php script!". 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. //This is a comment/*This isacomment block*/ Condition Statements Now these are fun to play with , they are used to execute certain code on a condition. <?php$mybrowser = "Fire Fox";if ($mybrowser == Fire Fox) { echo " You are using firefox!"; }else { echo " You are not using firefox"; }?> So here i have set a variable equal to my browser then made a condition, if my browser is equal to firefox, output "You are using firefox" else (if your using something else) output "You are not using firefox" . Ofcourse this will not work untill i i add more to it but it give's you all a idea how condition statements work. 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". <?php$z = 1;while ($z <= 5) {echo $z;$z++} Again i made a variable named z with the value of 1 , then stated while z is less or equal to 5 while ($z <= 5)output the value of z echo $z , increase z by 1$z++. Which would output 1-5 on your page. Simple isn't it? 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. <form action="form.php" method="post">Name: <input type="text" name="name"><input type="submit" value="Submit"> That's the html form , very simple. Now to the fun part. <?php$name = $_POST["name"];echo "Hello ". $name;?> Now here you have noticed something new and that would be "$_POST["name"]", $_POST is a variable already set by php , it recieved the information givin in the html form , notice the name="name" in the html form and ["name"] in $_POST. 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 If you wish to learn more about PHP you may visit some links to tutorial's i will provide you below. PHP.Net - Recommended W3Schools - Recommended Edited November 10, 2005 by BuffaloHELP (see edit history) Share this post Link to post Share on other sites
electriic ink 1 Report post Posted November 10, 2005 Good explanation. Some comments: This code: <?php$mybrowser = "Fire Fox";if ($mybrowser == Fire Fox) { echo " You are using firefox!"; } else { echo " You are not using firefox"; }?> Should be: <?php$mybrowser = "Fire Fox";if ($mybrowser == "Fire Fox") { echo " You are using firefox!"; } else { echo " You are not using firefox"; }?> With the quotes around if ($mybrowser == "Fire Fox") { Otherwise, you'll get an error like: Parse error: parse error, unexpected T_STRING in /home/xxxxxx/public_html/xxxxx.php on line XX Share this post Link to post Share on other sites
XRated 0 Report post Posted November 10, 2005 Right you are , yea never noticed i was missing double quote's.. Thank's for noticing that ill need to fix that Share this post Link to post Share on other sites
SvVifT 0 Report post Posted November 15, 2005 Wow this is a lot of writing and this is only the basics? omg Share this post Link to post Share on other sites
hulunes 0 Report post Posted November 15, 2005 woW,it is really an awesome tutorial.although i know PHP not bad,i'd like to learn some from here unobtrusively...to be continue...this topic Share this post Link to post Share on other sites
round 0 Report post Posted November 15, 2005 this is a very weird tutorial, concidering it's just rehashing what's in the manual. It might be more interesting to write a bit of code and go over the logic for it instead of going over functions & stuff.round. Share this post Link to post Share on other sites
HeroDP 0 Report post Posted November 15, 2005 its complicated, but is the best languaje for me Share this post Link to post Share on other sites
HmmZ 0 Report post Posted November 15, 2005 its a very completed language, covering the most wide aspects and possibilities of weblanguage, you may say that for example ASP is another great language, but my experience with that is the slowness of the language. I have never had wellmade pages that actually loaded instantly, while doing the exact same thing in PHP gives me instant pages.The language is dynamic, fast and is very well-understandable for both beginners as experts, aswell as it being a great challenge to anyone.Besides of that. the PHP community is one of the most friendly communities i have ever come across with, together with Xisto of course :lol:People help you if you help them. People support you as much as they can and try their best to keep the community a great place for everyone. No question is weird or wrong and that is the key to being a successful community! Share this post Link to post Share on other sites
XRated 0 Report post Posted November 16, 2005 its a very completed language, covering the most wide aspects and possibilities of weblanguage, you may say that for example ASP is another great language, but my experience with that is the slowness of the language. I have never had wellmade pages that actually loaded instantly, while doing the exact same thing in PHP gives me instant pages. The language is dynamic, fast and is very well-understandable for both beginners as experts, aswell as it being a great challenge to anyone. Besides of that. the PHP community is one of the most friendly communities i have ever come across with, together with Xisto of course People help you if you help them. People support you as much as they can and try their best to keep the community a great place for everyone. No question is weird or wrong and that is the key to being a successful community! 205253[/snapback] Very well said , couldn't of said it any better Share this post Link to post Share on other sites