![]() |
|
Technology Computing, programming, science, electronics, telecommunications, etc. |
![]() |
|
Thread Tools | Display Modes |
![]() |
#1 |
whig
Join Date: Apr 2001
Posts: 5,075
|
![]()
I've been doing a few little things in PHP over the last week for a particular purpose and i'm confused about one thing
I've got a script that refers to itself when it runs, checking a value ($id) that would have been set if the page/script is beign viewed for the second time the code to check that is if ($id) { blahblabla } Which as i thought checked that $id existed (in the url). It doesn't seem to work. If i get $id to check against a certain value i know it will be it works, but clearly the person who told me this was wrong or i've totally missed something. Any ideas from the crowd?
__________________
Good friends, good books and a sleepy conscience: this is the ideal life. - Twain Last edited by jaguar; 03-06-2003 at 01:26 AM. |
![]() |
![]() |
![]() |
#2 |
I thought I changed this.
Join Date: Nov 2002
Location: western nowhere, ny
Posts: 412
|
Newer installs of PHP have a config option (register_globals) off. When it is on, GET, POST, and cookie variables are automagically set. Load foo.php?bar=baz, and $bar will be 'baz' within the script. It was disabled by default to protect people with horribly atrocious coding standards from people sending them bogus value and faking authentication.
Use $_GET['id']. |
![]() |
![]() |
![]() |
#3 |
Radical Centrist
Join Date: Jan 2001
Location: Cottage of Prussia
Posts: 31,423
|
Also, personally speaking I avoid such shortcuts. C programmers love to write weird conditions that take hours to figure out. That's not so critical when performance is not the major factor. If I have a php script that goes to page two, I write something really bloody obvious like
if ($page2 == "yes") // --- Page TWO section ---------------- ...because even though it takes more effort now, it means I'll be able to figure out what I did a year from now, when I've forgotten the whole project and the client wants me to change the whole thing. |
![]() |
![]() |
![]() |
#4 |
Guest
Posts: n/a
|
I would be fired if I didn't write clean, well-commented code. I'm in the habit now of writing more comment than code. It's just something you get used to.
|
![]() |
![]() |
#5 |
He who reads, sometimes writes.
Join Date: Sep 2001
Location: at the keyboard
Posts: 791
|
I've always had the mindset that if your vars and funcs were well-named, then you wouldn't necessarily need to comment. Then my last perl script came to 1500 lines before completion. Yikes!
|
![]() |
![]() |
![]() |
#6 |
Guest
Posts: n/a
|
That's how I used to be. Unfortunately, they don't stand for that shit here.
|
![]() |
![]() |
#7 |
Professor
Join Date: Jan 2001
Posts: 1,788
|
If you can't understand it from a non-symbolic disassembly listing, you don't belong in the business, that's what I always say.
|
![]() |
![]() |
![]() |
#8 |
dripping with ignorance
Join Date: Oct 2002
Location: Grand Forks ND
Posts: 642
|
I realized this week that I have no idea how to program in Java anymore, I took it my first semester and now couldn't write a line of code without a book.
Okay I'm done crying now.
__________________
After the seventh beer I generally try and stay away from the keyboard, I apologize for what happens when I fail. |
![]() |
![]() |
![]() |
#9 |
whig
Join Date: Apr 2001
Posts: 5,075
|
Thanks skunks, the info dated to php3 (which i was not aware of). It's not anything related to anything authish so faking a var is not an issue, though i'll admit it's sloppy as hell, php is not a language i claim to know at all, i'm just playing around atm.
UT the code is commented etc, i just put the minimum to get the point across.
__________________
Good friends, good books and a sleepy conscience: this is the ideal life. - Twain |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|