/    Sign up×
Community /Pin to ProfileBookmark

Code outdated?

While reading the WROX book ‘Professional PHP Programming’, I came across an example where the code is outdated I believe. At the time of writing, the examples are written using PHP3.x.

In a text field named ‘user’, after the guest types their name and clicks submit, it takes them to a php page with the following code:

[code=php] <?php echo(“Welcome ” . $user); ?> [/code]

Testing this out using PHP5, I knew it wouldn’t work and I had to use

[code=php] <?php echo(“Welcome ” . $_POST[user]); ?> [/code]

My question is, is this book extremely outdated? Is there going to be [I]a lot[/I] of outdated information that would completely mess my programming? Is it still worth reading this book even though it’s PHP3? Is there a website that lists all the changes from PHP3 to PHP5?

To get a better idea, you can view the book i’m reading [URL=http://www.amazon.com/exec/obidos/tg/detail/-/B0000B0T0W/qid=1113107208/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/103-2472510-4524629?v=glance&s=books&n=507846]here[/URL]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@HaganeNoKokoroApr 10.2005 — The likely cause is that your installation of php has register_globals=off in php.ini. register_globals automatically creates variables named after autoglobal entries such as the items in $_GET and $_POST

The book is not out of date, but it does make the assumption (it may assert this assumption somewhere so you are aware of it) that you have register_globals=on
Copy linkTweet thisAlerts:
@MstrBobApr 10.2005 — The likely cause is that your installation of php has register_globals=off in php.ini. register_globals automatically creates variables named after autoglobal entries such as the items in $_GET and $_POST

The book is not out of date, but it does make the assumption (it may assert this assumption somewhere so you are aware of it) that you have register_globals=on[/QUOTE]


Well, from reading the reviews, the book covers PHP 3. In which case I would really recommend going for a more recent book. PHP 4 brought in a vast amount of functions, and I believe changes to the OOP. Zend is starting to shift towards PHP 5, though PHP 4 is still the standard.

I often prefer Registered Globals off, but you'll find that there are numerous differences between the PHP versions. If you look around the PHP manual, you can see it.

http://www.php.net/

I suppose that basic programming ideas still hold true, but I'd recommend looking at a resource then that covers PHP 4 at least, if you don't want to just make the jump to PHP 5.
Copy linkTweet thisAlerts:
@HaganeNoKokoroApr 10.2005 — I didn't mean to say the book wasn't out of date, rather that out-of-date-ness wasn't really the cause of the problem in this case.
Copy linkTweet thisAlerts:
@spufiApr 10.2005 — I didn't mean to say the book wasn't out of date, rather that out-of-date-ness wasn't really the cause of the problem in this case.[/QUOTE]

And if you do a search for the book on their site, that version doesn't come up, so you can't even get errata for it anymore.
Copy linkTweet thisAlerts:
@JayMauthorApr 10.2005 — I actually managed to get the eBook version of it. I would not purchase a PHP3 book. I do have the O'Reilly PHP programming book by Rasmus Lerdof but I've always been a big fan of WROX books.
Copy linkTweet thisAlerts:
@Stephen_PhilbinApr 10.2005 — Personally I just stick with www.zend.com

It's rather yummy. ?
Copy linkTweet thisAlerts:
@spufiApr 10.2005 — I've always been a big fan of WROX books.[/QUOTE]

Ditto. I'm luke warm on O'Reilly. You could also check out Site Point's books. Their intro PHP/MySQL book is good besides not including a couple very important pieces of code that you need to really make the application you build work. I am getting good use out of the anthology books though.
Copy linkTweet thisAlerts:
@JayMauthorApr 10.2005 — Ditto. I'm luke warm on O'Reilly. You could also check out Site Point's books. Their intro PHP/MySQL book is good besides not including a couple very important pieces of code that you need to really make the application you build work. I am getting good use out of the anthology books though.[/QUOTE]

Well I just happened to get my hands on a few of these *.pdf eBooks. Someone must have photocopied them ? . To be honest I have never read any O'Reilly books so I will 'not judge the book by its cover' :p . I have not checked out www.zend.com so I will check it out. I guess what I will do is I will try to learn from the o'reilly, wrox, php.net and zend.com all together :eek:
Copy linkTweet thisAlerts:
@ShrineDesignsApr 10.2005 — PHP 3 by default used register_globals = On, while in later version register_globals = Off.

it is best to code around register_globals turned off, it makes the scripts you write, readable

not to mention the vast security holes register_globals = On causes
×

Success!

Help @JayM spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...