Tutorial: PHP For Beginners Lecture
Author: fiber And Ross
Date: 11th Janurary 2003
Level: Beginner
Note:: This version was cropped and logged by Ross.
fiber :: www.fiber-t3ch.net
ross :: www.zc.ad.com
Session Start: Sat Jan 11 00:28:33 2003
Session Ident: #lecture
[01:03:16] * fiber sets mode: +v Ross
[01:03:18] <@fiber> no
[01:03:19] <@fiber> :)
[01:03:20] <@fiber> ok
[01:03:22] <@fiber> i'm starting
[01:03:24] <@fiber> :)
[01:03:30] <@interpol> all systems go
[01:03:31] * SooT (~bgates@zoite-5385.sabrna01.az.comcast.net) has joined #lecture
[01:03:32] * fiber sets mode: +m
[01:03:40] <@Null> (hi soot)
[01:03:44] <@fiber> Ok, thanks everyone for coming here. as most of you know, this is lecture
[01:03:45] <@fiber> number one in a 4 part series. This one is to teach PHP basics. I hope
[01:03:45] <@fiber> everyone can learn something :). Oh, and just for reference, if you want to ask
[01:03:45] <@fiber> a question, PM (private message) someone with an op, other than me and ask them
[01:03:46] <@fiber> the question, then i will say it to the channel if it's worthy ;). I hope you
[01:03:49] <@fiber> all learn something and find this fun ^_^
[01:04:12] <@fiber> and now to begin
[01:04:16] <+Ross> fuzzy8021 - lecture in progress --
[01:04:20] <@fiber> What is PHP?/Basic
[01:04:22] <@fiber> PHP is a server side web applications programming language. This means that you
[01:04:22] <@fiber> can create websites that generate output dynamically. Because of this, your
[01:04:22] <@fiber> website can be more interactive (web counters, guestbooks, etc.), but you also
[01:04:23] <@fiber> need access to a server with PHP installed. I have been told that Lycos offers
[01:04:25] <@fiber> free server space with PHP, and you can also make your own server. PHP code is
[01:04:27] <@fiber> embedded in HTML (I'm guessing you at least know HTML for this lecture). Also,
[01:04:30] <@fiber> is desirable have the extension *.PHP file instead of *.PHPL. Here is an
[01:04:33] <@fiber> example (this file is named "test.php"):
[01:04:35] <@fiber>
my first PHP site
[01:04:37] <@fiber> this is in HTML
[01:04:39] <@fiber>
[01:04:43] <@fiber> echo "this is in PHP
";
[01:04:46] <@fiber> echo "this is also in PHP
";
[01:04:48] <@fiber> ?>
[01:04:50] <@fiber> EOF
[01:04:52] <@fiber> Now, you can see how PHP is embedded into a HTML file, PHP and HTML coexist in
[01:04:54] <@fiber> one file, but you are not limited to only PHP. You can also have JavaScript, or
[01:04:58] <@fiber> any other language. Just remember, anything between the and ?> is PHP.
[01:05:14] <@fiber> by the way, that's .html, not .PHPl
[01:06:14] <@fiber> qwerty brings the point that and ?> only work if you have it set in PHP.ini
[01:06:25] <@fiber> but, it is normally set to handel thouse tags
[01:06:28] <@fiber> so you should be OK
[01:06:32] <@fiber> also work
[01:06:51] <@fiber> i'm guessing everyone is done
[01:06:57] <@fiber> now for the next section
[01:07:07] <@fiber> and by the way
[01:07:16] <@fiber> http://php.net has great documentation
[01:07:23] <@fiber> and PHP is available at that site also
[01:07:33] <@fiber> Variable Manipulation
[01:07:34] <@fiber> Variables are little pieces of memory you can use to hold data.
[01:07:34] <@fiber> Variables in PHP are very different than those in C/C++ or Java. In PHP, you
[01:07:34] <@fiber> don't need to initiate them, you just use them. This would also mean that there
[01:07:35] <@fiber> are no variable types. A string is an int is a char is an array, etc. Another
[01:07:37] <@fiber> difference is that all variables start with "$" (including arrays). Here is an
[01:07:43] <@fiber> example of variable manipulation:
[01:07:50] <@fiber>
[01:07:51] <@fiber> 1 $double=4.89;
[01:07:51] <@fiber> 2 $string = $double;
[01:07:51] <@fiber> 3 echo $double.":".$string;
[01:07:53] <@fiber> 4 //outputs "4.89:4.89"
[01:07:55] <@fiber> 5 $hello = "hello";
[01:07:56] <@fiber> 6 $hello .= "world!";
[01:07:59] <@fiber> 7 echo $hello;
[01:08:01] <@fiber> 8 //outputs "hello world!"
[01:08:03] <@fiber> ?>
[01:08:09] <@fiber> Some people may be a little bit confused about this example. The '.' Is the
[01:08:10] <@fiber> operator to join things as a string. You can see in line 3 that it outputs a
[01:08:12] <@fiber> string of the contents of $double, a space, semicolon, space, then the values of
[01:08:16] <@fiber> $string. Also, '.=' on line 6 is the same as doing $hello=$hello."world!". This
[01:08:18] <@fiber> can be used with everything (ie: += -= *= /=, etc.)
[01:08:56] <@fiber> remember, questions go to OPs in PM's
[01:09:12] <@fiber> ie: /msg interpol
[01:09:26] <@fiber> cskaterun wants to know about global variables
[01:09:31] <@fiber> now, variables all have scopes
[01:10:06] <@fiber> if a variable is made in a function (which will be later explained) it will only exist in that function
[01:10:31] <@fiber> but, if a variable is created in the main program, outsite the function, it is availible everywhere, also you can delare globarl variables
[01:11:06] <@fiber> you can do this by doing:
[01:11:11] <@fiber> global $variablename;
[01:11:40] <@fiber> also
[01:11:44] <@fiber> if you do this:
[01:11:53] <@fiber> $name = "Ross"; ?> Some HTML Here echo $name; ?>
[01:12:09] <@fiber> the variable $name will still be availible in the next PHP bracket
[01:12:19] <@fiber> any further questions on this section?
[01:12:44] <@fiber> an further
[01:12:59] <@fiber> there are some preset variables ( cskaterun wants to know about them)
[01:13:28] <@fiber> these variables hold different sets of information about the server
[01:13:50] <@fiber> they can be found at http://www.php.net/manual/en/language.variables.predefined.php
[01:13:52] <@fiber> :)
[01:13:57] <@fiber> ok, time for the next section
[01:14:16] <@fiber> err... before that
[01:14:32] <@fiber> it can tell you different variables, and stats on the server and what it can handle
[01:15:01] <@fiber> now, the next section, and it's final this time :)
[01:15:10] <+Ross> :p
[01:15:11] <@fiber> Now to talk about arrays. First, the example:
[01:15:12] <@fiber>
[01:15:12] <@fiber> 1 $color=array("red","orange","blue","yellow");
[01:15:12] <@fiber> 2 $string = implode($color,";");
[01:15:12] <@fiber> 3 //string is now "red;orange;blue;yellow"
[01:15:12] <@fiber> 4 $string .= ";black";
[01:15:14] <@fiber> 5 $color = explode($string,";");
[01:15:15] <@fiber> 6 //$string has been cut into an array on every ';'
[01:15:18] <@fiber> 7 echo $color[0]." ";
[01:15:20] <@fiber> 8 echo $color[1]." ";
[01:15:21] <@fiber> 9 echo $color[2]." ";
[01:15:24] <@fiber> 10 echo $color[3]." ";
[01:15:27] <@fiber> 11 echo $color[4]." ";
[01:15:29] <@fiber> 12 //will output "red orange blue yellow black"
[01:15:30] <@fiber> 13 echo "/n".count($color);
[01:15:32] <@fiber> 14 //will output "5" on a new line
[01:15:34] <@fiber> 15 //Note: new line is only visible in console, use
on the web
[01:15:36] <@fiber> ?>
[01:15:47] <@fiber> Many may be turned off to PHP by seeing this, but it was written the
[01:15:48] <@fiber> long way to display array manipulation. Line 1 makes an array. This could also
[01:15:51] <@fiber> be done by adding to $color manually into each element ($color[0]="red;"; etc.)
[01:15:54] <@fiber> Next, we implode the array. This is a very important PHP function that takes an
[01:15:56] <@fiber> array and turns it into a string. In addition, it adds the second parameter in
[01:16:00] <@fiber> between 2 elements. Note: an element is a piece of an array, in this example
[01:16:03] <@fiber> each color. Now you may have noticed that I refer to $color[0] a lot. This is
[01:16:06] <@fiber> because the first element in an array is 0. On line 5, a string put into array
[01:16:09] <@fiber> and cut every time there is a ";". Another note, line 13 will output "5" which
[01:16:11] <@fiber> is the human value for how many values there are. To the computer, there are 4,
[01:16:14] <@fiber> because there is a 0th element (the array starts at 0). Lines 7-11 are
[01:16:17] <@fiber> outputting are outputting the elements individually. Also, if you have an array
[01:16:22] <@fiber> w/ information and you would do it like this. By the way, you could have also
[01:16:25] <@fiber> just done $color[4] = "black" or array push($color, "black") to add black at the
[01:16:28] <@fiber> end of the array :). Any Questions? ;)
[01:16:30] <@fiber> (i'm sorry if the lines wrap, i use double monitors so i can handel wider lines)
[01:18:27] <@fiber> if anyone has any quesitons, ask them to an OP
[01:18:34] <+Ross> ok people
[01:18:40] <@fiber> ok, Ross is explaining something
[01:18:41] <@fiber> :)
[01:19:02] <+Ross> while on the subject of array's i would like to point out a very usful function
[01:19:10] <+Ross> the explode function, explode();
[01:19:15] <+Ross> the syntax is as follows
[01:19:32] <+Ross> explode([small string] , [big string]);
[01:19:34] <+Ross> basically
[01:19:54] <+Ross> if you have a string containing $string = "hello:::there";
[01:20:21] <+Ross> and type: $array = (":::",$string);
[01:20:31] * nirvana (Mr@zoite-23428.ipt.aol.com) has left #lecture
[01:20:58] <+Ross> what this does is breaks $string down by adding all the text up until ::: to the $array
[01:21:00] <+Ross> for example
[01:21:10] <+Ross> $array[0] will = hello
[01:21:19] <+Ross> $array[1] will = there
[01:21:48] <@fiber> :)
[01:21:49] <@fiber> thank you
[01:21:54] <+Ross> ask me if u dont understand
[01:21:54] <@fiber> and for dday, HTML stands for hyper text transfer protocol ;)
[01:22:35] <@fiber> any other questions?
[01:22:55] <@fiber> err
[01:22:57] <@fiber> http
[01:22:59] <@fiber> :)
[01:23:32] <@fiber> html = hyper text markup language?
[01:23:57] <+Ross> yup
[01:24:36] <@fiber> $var = array("0" -> "foo"); askes qwerty
[01:24:49] <@fiber> would that be easier than imploding?
[01:25:24] <+Ross> well, thats a dimensional array
[01:26:02] <@fiber> there is is
[01:26:07] <@fiber> :)
[01:26:31] <@fiber> it would work
[01:26:35] <+Ross> echo $var[0] would echo foo
[01:26:45] <@fiber> :)
[01:26:55] <+Ross> one could use
[01:27:07] <+Ross> $var = array("tool" -> "saw");
[01:27:14] <+Ross> echo $var['saw'];
[01:27:17] <+Ross> sorry
[01:27:22] <+Ross> echo $var['tool'];
[01:27:28] <+Ross> which would echo say
[01:27:29] <+Ross> *saw
[01:27:41] <+Ross> think of it like this
[01:28:26] <+Ross> its a multi dimensional array, like a shape, a 2d shape can only show a single face layer, but with a 3d shape, there is more to it that one value
[01:29:38] <@fiber> ok
[01:29:42] <@fiber> now for the next section
[01:29:50] <@fiber> and remember, ask any questions that come to mind :)
[01:29:53] <@fiber> File Manipulation
[01:29:54] <@fiber> If you want to make something interactive, you might want to store
[01:29:54] <@fiber> information. An example would be for a counter. You need to keep the counter
[01:29:54] <@fiber> number somewhere. Here is an example of a counter:
[01:30:13] <@fiber>
[01:30:13] <@fiber> 1 $number=file("counter.txt");
[01:30:13] <@fiber> 2 //$number becomes an array
[01:30:13] <@fiber> 3 //each line of counter becomes an array element.
[01:30:13] <@fiber> 4 $number - trim(implode($number, ""));
[01:30:14] <@fiber> 5 //implodes all of the elements of the array into a single variable
[01:30:16] <@fiber> 6 //and takes away any spaces from the beginning and end.
[01:30:19] <@fiber> 7 $number++;
[01:30:21] <@fiber> 8 //adds one to the number
[01:30:23] <@fiber> 9
[01:30:25] <@fiber> 10 echo "$number people came here";//output
[01:30:26] <@fiber> 11
[01:30:28] <@fiber> 12 $file=fopen("counter.txt", "w+"); //opens counter.txt with w+
[01:30:30] <@fiber> 13 //puts into obj file.
[01:30:32] <@fiber> 14 fputs($file, $number); //puts $number in file rep. by $file
[01:30:35] <@fiber> 15 fclose($file); //closes the file in the resource $file
[01:30:37] <@fiber> ?>
[01:30:39] <@fiber> I think that lines 1-10 are self explanatory, so I will be focusing on the rest
[01:30:42] <@fiber> of them. Line 12 opens the file and has $file (which can be called anything as
[01:30:47] <@fiber> you want) as the resource, or object. Let me elaborate. The "counter.txt"
[01:30:50] <@fiber> specifies what file will be opened. Then "w+" tells how its opening the file.
[01:30:53] <@fiber> These are the different ways of opening a file.
[01:30:54] <@fiber> * 'r' - Open for reading only; place the file pointer at the beginning of the
[01:30:58] <@fiber> file.
[01:31:00] <@fiber> * 'r+' - Open for reading and writing; place the file pointer at the beginning
[01:31:04] <@fiber> of the file.
[01:31:05] <@fiber> * 'w' - Open for writing only; place the file pointer at the beginning of the
[01:31:08] <@fiber> file and truncate the file to zero length. If the file does not exist, attempt
[01:31:11] <@fiber> to create it.
[01:31:13] <@fiber> * 'w+' - Open for reading and writing; place the file pointer at the beginning
[01:31:16] <@fiber> of the file and truncate the file to zero length. If the file does not exist,
[01:31:20] <@fiber> attempt to create it.
[01:31:21] <@fiber> * 'a' - Open for writing only; place the file pointer at the end of the file. If
[01:31:27] <@fiber> the file does not exist, attempt to create it.
[01:31:29] <@fiber> * 'a+' - Open for reading and writing; place the file pointer at the end of the
[01:31:31] <@fiber> file. If the file does not exist, attempt to create it.
[01:31:34] <@fiber> (Taken from php.net)
[01:31:36] <@fiber> Now, the fopen function returns a value which is a resource pointing to
[01:31:39] <@fiber> the opend file. This means that from now on $file will refer to the file. Then,
[01:31:41] <@fiber> fputs($file, $number) puts the contents of $number in the file that $file points
[01:31:44] <@fiber> to. The data is put wherever the pointer is (look at ways of opening a file) and
[01:31:46] <@fiber> if the pointer is at the beginning of the file and you send data to it, it
[01:31:49] <@fiber> clears everything after the pointer. And finally fclose($file) closes the file.
[01:31:53] <@fiber> Questions?
[01:31:57] <@fiber> remember, ask questions to OP's or Ross
[01:32:00] * fiber sets mode: -o interpol
[01:32:05] <@fiber> not to interpol
[01:32:06] <@fiber> :)
[01:32:13] * fiber sets mode: +o Ross
[01:32:30] <@fiber> and bythe way
[01:32:33] <@Ross> For IIS Users, you wont be able to write to a file until yopu have changed its file permissions. This can be done by loading the IIS GUI, in the tree menu to the left, navigate to your current site in the Web Sites node. Find the web site, right click it and select properties. Select Write permisions. Now click ok and navigate to the text file or php file you wish to write to and right click it, s
[01:32:33] <@Ross> select "all tasks" then permissions wizard
[01:32:55] * fiber sets mode: +o interpol
[01:33:10] <@fiber> ok, if you are using linux on your server
[01:33:17] <@fiber> you might need to chmod the file to use it
[01:33:31] <@fiber> you can use the function chmod(string filename, int mode)
[01:33:41] <@fiber> it only takes octal modes
[01:33:43] <@fiber> :)
[01:34:00] <@Ross> a good mode to use is 644 or, if your not security concious , 777, which is the maximium value
[01:34:05] <@Ross> question #2: can you pull syntac's finger?
[01:34:19] * @fiber pulls syntac's finger
[01:34:35] <@fiber> if you are going to modify a file with a script, chmod it to 777
[01:35:01] * fiber sets mode: -o interpol
[01:35:08] <@fiber> any further questions?
[01:35:19] <@Ross> question #3: is this lecture almost finished?
[01:35:33] <@fiber> yup :)
[01:35:43] <@fiber> ok
[01:35:48] <@fiber> now for the next section
[01:37:30] <@fiber> now, next section if there aren't any questions
[01:37:44] <@fiber> mySQL
[01:37:45] <@fiber> And now for the section a lot of people have been waiting for, mySQL.
[01:37:45] <@fiber> This section might be confusing for a lot of you, so I recommend testing I out
[01:37:45] <@fiber> (that's how I learned this). Also, this section is a little bit more advanced,
[01:37:47] <@fiber> so I recommend first getting a hold on the basics, then coming back to this.
[01:37:49] <@fiber> For people who don't know what mySQL is, it's a free database system, which
[01:37:52] <@fiber> means for example, you can have a database called "BBS" and inside a table for
[01:37:55] <@fiber> each different thread of the BBS. Each table can have a field of Name, and one
[01:37:58] <@fiber> for Message, etc.. For this section, I'm hoping you have background knowledge,
[01:38:02] <@fiber> but if you have none it'll take you little longer. And now, for an example to
[01:38:05] <@fiber> analyze:
[01:38:29] <@fiber>
[01:38:29] <@fiber> 1 $mysql_server = "localhost";
[01:38:29] <@fiber> 2 $mysql_server_user = "";
[01:38:29] <@fiber> 3 $mysql_server_pass = "";
[01:38:29] <@fiber> 4
[01:38:30] <@fiber> 5 //This connects to the mySQL database and if it fails, stops running and
[01:38:33] <@fiber> 6 // says "Database error: Couldn't conect"
[01:38:35] <@fiber> 7 $link = mysql_connect($mysql_server, $mysql_server_user,
[01:38:37] <@fiber> $mysql_server_pass)
[01:38:38] <@fiber> 8 or die("Database error: Couldn't connect");
[01:38:41] <@fiber> 9
[01:38:42] <@fiber> 10 //Uses a database called "topsites" and if it's not found stop script
[01:38:45] <@fiber> and
[01:38:50] <@fiber> 11 // say that it couldn't find the database
[01:38:51] <@fiber> 12 mysql_select_db("topsites")
[01:38:55] <@fiber> 13 or die("Database error: Database not found");
[01:38:56] <@fiber> 14
[01:38:59] <@fiber> 15
[01:39:01] <@fiber> 16 // This sends the command to get all fields from the table "sites" and
[01:39:02] <@fiber> also
[01:39:05] <@fiber> 17 // says only to show the first 50 results. By the way, $result only
[01:39:09] <@fiber> becomes
[01:39:19] <@fiber> 18 // a link to where the information is. Remember: you can have multiple
[01:39:20] <@fiber> tables in one database
[01:39:20] <@fiber> 19 $result = mysql_query("SELECT * FROM sites LIMIT 50;");
[01:39:23] <@fiber> 20
[01:39:25] <@fiber> 21
[01:39:26] <@fiber> 22 // Here is where the magic happens, what this does is, as long as it is
[01:39:29] <@fiber> able to
[01:39:31] <@fiber> 23 // get the new row of information and put it into a new element of the
[01:39:35] <@fiber> array.
[01:39:36] <@fiber> 25 $i = 0;
[01:39:38] <@fiber> 26 while ($sites[$i] = mysql_fetch_row($result))
[01:39:40] <@fiber> 27 $i++;
[01:39:43] <@fiber> ?>
[01:39:45] <@fiber> EOF
[01:39:47] <@fiber> Now just for clarification, this is the command i used to make the
[01:39:49] <@fiber> table:
[01:39:50] <@fiber> mysql> create table sites(sitename varchar(20), url tinytext, burl tinytext,
[01:39:58] <@fiber> description text, adminvote float, vote float, hitsin int, hitsout int, id int);
[01:39:59] <@fiber> EOF
[01:40:01] <@fiber> The result of this is the variable $sites being a 2D array. The first dimension
[01:40:04] <@fiber> would be the site, and the second dimension being the different site attributes
[01:40:07] <@fiber> (if you look at how the table was made, sitename would be [0], url would be [1].
[01:40:11] <@fiber> For example, "echo $site[0][1];" would output the URL of the first site
[01:40:13] <@fiber> (remember, arrays start at zero). And now to show how this works. Never are
[01:40:16] <@fiber> you actually getting human data from the database until line 26. what 1-13 does
[01:40:19] <@fiber> is actually connect to the database and changing the database it's using (can be
[01:40:21] <@fiber> simplified, but this is more organized and easier to understand). Then, line 19
[01:40:24] <@fiber> sends the command to the connected mySQL server (remember, it's as if you typed
[01:40:28] <@fiber> it directly to the mySQL client so you need the ; and sometimes even quotes).
[01:40:30] <@fiber> line 25 initiates a counter (because we are using $i++ we need it to have a
[01:40:35] <@fiber> commencing value) and then as long as it's able to get a whole row of data from
[01:40:39] <@fiber> the database, it will add one to the counter (changing which element it's
[01:40:42] <@fiber> dumping the information into) and do it again. The reason that this works is
[01:40:45] <@fiber> every time you do an operations (even $var = 1+1) it returns a boolean (true or
[01:40:53] <@fiber> false). If it is able to carry out the operation, it returns true, if it can't
[01:40:56] <@fiber> do it, it returns a false. So this statement keeps going while that statement
[01:40:59] <@fiber> is true, meaning it does it till it gets an error. Once again, it puts every
[01:41:03] <@fiber> different column or different type of data (such as sitename and tinytext) into
[01:41:06] <@fiber> a different array (which in this case would be the 2nd dimention). Any by the
[01:41:09] <@fiber> say, mysql_fetch_row uses numberd indexies (that's why it would be [0]... etc,
[01:41:11] <@fiber> but you can use mysql_fetch_assoc and then it'd make the indexies the field
[01:41:14] <@fiber> names, so it would $site[0]["url"] instead of $site[0][1].
[01:41:18] <@fiber> Well, that's the mySQL basics, there are ALOT more things you can do with mySQL,
[01:41:21] <@fiber> this was to teach you concept. In later lectures i will be going into more
[01:41:24] <@fiber> details. if you want more information, go to http://php.net/mysql or
[01:41:27] <@fiber> http://mysql.com (go to the mySQL site for information on mySQL variable types,
[01:41:29] <@fiber> etc.).
[01:41:41] <@fiber> let me clarify something
[01:41:44] <@fiber> some people aren't sure that you put the semicolen in the quotes in line 19
[01:41:59] <@fiber> (19 $result = mysql_query("SELECT * FROM sites LIMIT 50;");)
[01:42:09] <@fiber> this is done because you are acctually sending that string to the mySQL server
[01:42:16] <@fiber> it sends that string EXACTLY
[01:42:36] <@fiber> and, when you type directly into a mySQL client, every statment requires and ending ';'
[01:42:46] <@Ross_> by adding file.sql to the end of the mysql login syntax, it will load the sql script and execute it.
[01:43:00] <@fiber> also
[01:43:26] <@fiber> it automaticaly sorts alfanumericaly with the first field of information
[01:44:26] <@fiber> any further questions on mySQL?
[01:44:53] <@fiber> by the way, the complete script for top50's will soon be on http://smart-dev.com :)
[01:45:27] <@fiber> qwerty mentions that you could also do "ORDER BY id DESC" do order it by the field id, and have it desend
[01:46:15] <@fiber> doing that, it would have the highest ID at the top, and lowest on the bottom if i'm correct
[01:46:41] <@Ross_> ORDER BY ID DESC LIMIT 4
[01:46:51] <@Ross_> would select the latest 4 in order if ID
[01:47:15] <@Ross_> Styx wants to know if mysql costs anythign
[01:47:19] <@Ross_> and the answer here is no
[01:47:31] <@Ross_> mySQL is a completly free database management system
[01:47:46] <@Ross_> released under the GNU managment agreemnt as far as i can remember
[01:47:47] <@fiber> ok, any further questions?
[01:48:16] <@fiber> ok, any further questions?
[01:48:37] <@fiber> Just to restate, any information on mySQL is available at mySQL.com :)
[01:49:04] <@fiber> and now, Ross wants to give a little section of his own on if...else if...else
[01:49:11] <@Ross_> :D
[01:49:15] <@fiber> Ross.... :)
[01:49:33] <@Ross_> often we will want to find out if soemthing is equal to somethign or if it isnt, then preform an action
[01:49:39] <@Ross_> for this we use the if statements
[01:49:52] <@Ross_> $nick = "Ross";
[01:50:00] <@Ross_> $nick2 = "Ross";
[01:50:08] <@Ross_> if ($nick == $nick2){
[01:50:16] <@Ross_> echo "The nicks are the same!";
[01:50:18] <@Ross_> }
[01:50:24] <@Ross_> this will result in a true statement
[01:50:36] <@Ross_> because $nick is equal to $nick2
[01:50:59] <@Ross> you will notice that i used == instrad of =
[01:51:18] <@Ross> theseare a called operators
[01:51:30] <@Ross> == means "is equal to"
[01:51:37] <@Ross> != means "is not equal to"
[01:51:50] <@Ross> <> etc, more information can be found on these at php.net
[01:52:08] <@Ross> obviously our statement wont always be true
[01:52:16] <@Ross> there fore we need to tell the code where to go if it isnt true
[01:52:22] <@Ross> $nick = "Ross";
[01:52:28] <@Ross> $nick2 = "not ross";
[01:52:36] <@Ross> if($nick == $nick2){
[01:52:41] <@Ross> echo "They are the same!";
[01:52:44] <@Ross> }else{
[01:52:50] <@Ross> echo "they are not the same!";
[01:52:52] <@Ross> }
[01:53:20] <@Ross> what this does is, check if the nicks are the same, if they are it prints "they are the swame!" other wise it prints "they are not the same"
[01:53:48] <@Ross> if we want to check more than one statement, we can use the else if
[01:53:58] <@Ross> $nick = "ross";
[01:54:06] <@Ross> $nick1 = "fiber";
[01:54:14] <@Ross> $nick2 = "jadz0r";
[01:54:25] <@Ross> if ($nick = $nick1){
[01:54:39] <@Ross> echo "nick and nick one are the same!";
[01:54:40] <@Ross> }
[01:54:46] <@Ross> elseif{
[01:54:55] <@Ross> --typo
[01:55:09] <@Ross> elseif($nick1 == $nick2){
[01:55:18] <@Ross> echo "nick 1 and nick 2 are the same!";
[01:55:19] <@Ross> }
[01:55:21] <@Ross> else {
[01:55:35] <@Ross> echo "None of the above are true";
[01:55:36] <@Ross> }
[01:55:52] <@Ross> any questions?
[01:56:03] <@fiber> by way, http://www.php.net/manual/en/language.operators.php and http://www.php.net/manual/en/control-structures.php should help you
[01:56:11] <@Ross> :D
[01:56:22] <@fiber> any questions about that or any other sections
[01:56:34] <@fiber> speak now or forever old your peace... :)
[01:56:48] <@Ross> hehe
[01:56:59] <@fiber> ok, well i guess we did a good
[01:57:02] <@fiber> job
[01:57:02] <@fiber> :)
[01:57:03] <@Ross> info from qwerty:
[01:57:05] <@Ross> mysql costs money if you are not releasing your product under the GPL
[01:57:07] <@fiber> Thanks everyone for coming to my lecture. I hope that it has helped everyone
[01:57:07] <@fiber> learn something new. Also, i hope you will be able to come to my next lectures
[01:57:07] <@fiber> and by the way, if anyone needs any PHP help, I'll always be here :)
[01:57:15] <@fiber> ah yes
[01:57:15] <@fiber> :)
[01:57:17] <@Ross> where exactly will this lecture be posted again?
[01:57:34] <@fiber> smart-dev.com, fiber-t3ch.net
[01:57:41] <@Ross> and at www.zc-ad.com
[01:57:57] <@fiber> and i'd like to thank Ross
[01:58:06] <@fiber> and everyone, if you have further discusion or questions
[01:58:11] <@fiber> go to http://zc-ad.com
[01:58:11] <@fiber> or ask us
[01:58:15] <@fiber> :)
[01:58:15] <@fiber> thanks for comming
[01:58:20] * fiber sets mode: -m
[01:58:24] <@Ross> ill sit around here for a bit
[01:58:24] * Styx claps
[01:58:28] yay
[01:58:28] encore
[01:58:32] <@fiber> :)
[01:58:32] encore
[01:58:37] * @fiber bows
[01:58:39] dose that mean we have to leave now
[01:58:42] very nice job
[01:58:42] * rose_red (rose_red@zoite-49672.resnet.ohio-state.edu) has joined #lecture
[01:58:47] * Styx stands
[01:58:47] yay
[01:58:47] * cskaterun stands up
[01:58:48] <@Ross> rose_red
[01:58:52] <@Ross> your justin time for the lecture
[01:58:52] * saszap claps
[01:58:52] hey, what is php?
[01:58:55] <@Ross> :p
[01:58:57] lol
[01:58:57] <@fiber> lol
[01:58:57] <@Ross> lmao
[01:59:02] hahahaha
[01:59:02] * chix0r smakx syntac
[01:59:02] you guys going to lecutre?
[01:59:02] may I answer that
[01:59:05] hi
[01:59:06] <@Ross> personal homepage hypertext preprocessor
[01:59:08] <@fiber> hehe
[01:59:09] :p
[01:59:13] no
[01:59:15] <@Ross> yes
[01:59:16] <@fiber> :)
[01:59:16] wrong
[01:59:18] <@Ross> it is
[01:59:27] incorrect
[01:59:27] I will lecture
[01:59:27] no
[01:59:27] lol
[01:59:27] tq ross and fiber
[01:59:28] <@Ross> what ur thinking is wrong
[01:59:31] <@Ross> i know for a fact
[01:59:31] it is not
[01:59:31] <@fiber> it is
[01:59:32] <@Ross> :p
[01:59:35] on pre marital sex
[01:59:35] yes, a rowsing ovation for Ross and fiber
[01:59:41] wtf
[01:59:45] <@fiber> thank you Styx
[01:59:45] dday will lecture about mentally challenged people
[01:59:49] <@fiber> lol
[01:59:54] since when was there a personal homepage in it
[01:59:59] * tam (~tam@zoite-14296.bbd09tcl.dsl.pol.co.uk) Quit (Quit: Client Exiting)
[01:59:59] lol
[02:00:04] <@Ross> hehe, get ur assess to www.zc-ad.com the forums there are dedicated to helping beginner programms scripters etc.
[02:00:05] unadvised has some nice views on mentaly challeneged people
[02:00:09] lol
[02:00:13] thx fiber and Ross, excellent lecture
[02:00:13] php: hypertext preprocessor
[02:00:13] apprently he think they can not get on irc
[02:00:18] tq ross and fiber
[02:00:22] <@Ross> no worries
[02:00:22] <@fiber> they had a different name for it before, but then they changed it but kept the meaning
[02:00:28] <@fiber> thanks morph, unadvised :)
[02:00:32] <@Ross> fiber, did u log it?
[02:00:35] <@fiber> and thank you to everyone who came and listend!
[02:00:41] then again maybe he just has this sterptypical view of mentaly challeneged people
[02:00:46] <@fiber> Ross: of course :)
[02:00:46] Ross: i thought you logged it
[02:00:50] <@Ross> i did
[02:00:50] * unadvised (unadvised@hotmail.com) has left #lecture
[02:00:54] <@fiber> i logged it
[02:00:55] <@Ross> but i was d/c i nthe middle
[02:00:56] <@Ross> lol
[02:00:58] <@fiber> :)
[02:00:58] <@Ross> send
[02:00:58] <@Ross> :S
[02:00:59] oh
[02:01:02] uzi lol that site is still up
[02:01:08] oooohh
[02:01:14] <@fiber> and i'm sorry about the disorder, it was my first lecture :-x
[02:01:25] <@Ross> dday, it was only put up like, about a week ago
[02:01:41] fiber, if you like we can put it on www.zoite.net too
[02:01:45] <@fiber> :) thanks morph
[02:02:02] ahh what was your old site again ?
[02:02:07] morph theres a messaqge from me your way
[02:02:09] i cant remember
[02:02:09] so we've got 3 sites to check out?
[02:02:20] zc-ad.com
[02:02:20] smart-dev.com
[02:02:20] * unadvised (unadvised@hotmail.com) has joined #lecture
[02:02:20] and fiber-t3ch.net?
[02:02:21] <@Ross> hehe
[02:02:23] <@fiber> yes sir
[02:02:25] <@fiber> fiber-t3ch.net
[02:02:29] zc-ad meaningf
[02:02:31] ok, just doulbe checkin
[02:02:35] <@Ross> old domain
[02:02:42] <@Ross> we're gettin secure-dev.com in a few days now
[02:02:43] <@Ross> ;)
[02:02:44] double even
[02:02:54] <@fiber> :)
[02:02:56] <@fiber> awesome
[02:04:19] so
[02:04:24] <@fiber> by the way, sends logs to fiber@smart-dev.com , i think mine looks ugly :-x
[02:04:28] we can leave now?
[02:04:34] <@Ross> no!
[02:04:38] darnit
[02:04:39] <@fiber> hehehe
[02:04:39] :p
[02:04:40] lol
[02:04:45] <@Ross> mine looks pretty
[02:04:46] <@Ross> :D
[02:04:47] <@fiber> you must stay in my dungon!!
[02:04:49] * saszap (imagine@zoite-6971.port.east.verizon.net) Quit (Quit: good night)
[02:04:52] dungeon?
[02:04:55] <@fiber> Ross: send it
[02:04:56] i dont wanna stay in your dung
[02:04:59] :p
[02:05:02] <@fiber> Styx: yea, that :-p