RE: [PHP] How to brainwash a C programmer, chapter 3

From: Date: Wed, 22 Nov 2000 10:10:49 +0000
Subject: RE: [PHP] How to brainwash a C programmer, chapter 3
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-26600@lists.php.net to get a copy of this message
Christian Dechery ... > MR wrote: > > > I created in pure C a pseudo-e-commerce system for my website. Since we > > > don't have databases (lack of cash) > > > >*ehem* > > > >Did you know that MySQL, a database format that PHP can deals very well > >with, is TOTALLY FREE?? > > I already installed MySQL here, and started playing with some queries... it > works fine... Well, you're going the right way... <HIDE> The brainwashing is going as planned, sir </HIDE> > > > I did it all with binary files. It > > > works fine... perfect. > > > >Until your binary file grows up to several megabytes, and loading a page > >can spend 20 or 30 secs... > > believe, that won't happen... but that's not the point! Yeah, i know that your 1 Ghz webserver deals quickly with files of a few megabytes, but anyway it's better to use a database to deal with that data sizes. > >What do you need? Show all the data in a array?? > > > >echo > >"<TABLE><TR><TD><B>Name</B></TD><TD><B>E-mail</B></TD></TR>"; > >while (list($name,$email)=each($friends)) > > { > > echo "<TR><TD>$name</TD>"; > > echo "<TD>$email</TD></TR>"; > > } > >echo "</TABLE>"; > > yeah... kinda obvious, but how do I get the data in the array? $array[key]=value; Simple huh? > that's my > question... not how I show it... how do I feed the array? you feed the array with next($array), prev($array), reset($array), end($array), and the each($array) itself. You have the PHP manual in HTML format, right?? > This thing of not > having to declare just makes me nuts... Naaah, i find that useful... I want an auxiliar variable, so i just use it, not even bothering if it's declared or not... Let PHP do the dirty work. > >Hahaha!! You'll get amazed when you see what the include() function does > >in PHP, believe me... > >You'll never though about functions returning several values through > >pointers... you'll think about subprograms copy-pasted into the > >main program that modify the values of the variables... > > what??????????? As you've read it... include() is *VERY* *FUNNY* in PHP for a C programmer as you... Let's make a couple of examples... I have a web site, and i want to put the same heading in every php page once parsed (i.e. i want the main title and some links in *every* page). How do i do that? I could read the file with fopen() and so, or i could do it the right way... using include()... Let's say that i have the file "title.php" that contains the HTML section of the page that includes the header part, and the uper part of every page (the title and links). To put it in a page, i just have to write include "title.php"; Simple huh? Second example, more difficult. I have a database, and i'm working with several database servers (i.e. my local server for testing, preview server in later development phase, and definitive server) (these are functions for mysql) Well, we have to connect to the database with one line of code: $connection=mysql_connect("server","user","password"); Well. Imagine i have to connect to the database in 10 or 15 PHP pages. And that it's possible for the database server to be changed at every moment. The right way to do this is making a "connect.php" file that contains only the upper line of code (within <? ?> of course). And in the real PHP page it should look as this: include "connect.php"; ... ... $query=mysql_query("select blahblah from blahblah where blahblah",$connection); You know, mysql_query needs the query string and the optional link identifier (connection identifier). Think for a moment that the link id is neccesary. What does that code? connect.php assigns to a variable named $connection the link id for the database, and without returning it or anything, $connection can be used outside from connect.php !!!!! See what i want to say with "include copy-pastes code"?? > >Well, they'll be that guys that program under micro$oft... get a person > >that programs PHP under unix, they all hate ASP! > > I hate ASP! And I don't even program in PHP... (not yet)... Resistance is futile... you will be assimillated.... :-D > I really need to be brainwashed... I once was, when I started to learn OO > in college... but I didn't like it all. And erased it all from my pointer > head. :) Don't hurry, this way you'll get brainwhased in 10 or 20 posts more... -- _ Iván Sánchez Ortega "MR" /|/| |_> MR.@wanadoo.es / | | | \ / | \ No, mum, don't touch that cab#@@%%## [NO CARRIER]

« previous php.general (#26600) next »