Computer Science Canada When $_GET['whatever'] has no value... |
Author: | HyperFlexed [ Tue Jul 24, 2007 10:28 am ] |
Post subject: | When $_GET['whatever'] has no value... |
I have a bit of a problem. I am building a site that has index.php. The page one is viewing is specified by a $_GET variable called 'page'. If I make a request to simply index.php, I get an error, because $_GET['page'] is undefined. What value does $_GET['page'] have when it isn't specified in the URL? I guessed the empty string "", but this doesn't seem to work. If all else fails, I can use MOD_REWRITE, but I'd like to avoid that if possible. |
Author: | Amailer [ Tue Jul 24, 2007 11:05 am ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Nothing, its not set use if isset(variable) to check if its set |
Author: | HyperFlexed [ Tue Jul 24, 2007 11:33 am ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Perfect THANK YOU! |
Author: | md [ Tue Jul 24, 2007 9:38 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
isset() returns if a variable has been set, it's a much better way of checking then seeing if it equals nothing |
Author: | rizzix [ Tue Jul 24, 2007 11:16 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
PHP is a badly designed language. Please try developing in something else. |
Author: | octopi [ Wed Jul 25, 2007 8:02 am ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
Rizzix, care to provide examples. Once you master the 'unique' naming scheme used by php (for functions) I don't find it bad at all. |
Author: | PaulButler [ Wed Jul 25, 2007 10:29 am ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
octopi @ Wed Jul 25, 2007 8:02 am wrote: Once you master the 'unique' naming scheme...
Or lack therof namespace_verb_noun (id3_get_tag) namespaceverbnoun (imagecreatefromjpeg) namespace_verbnoun (imap_getmailboxes) The "namespaces" really being pesudo-namespaces, since PHP does not have any way to define namespaces or packages. There is not even consistency within pseudo-namespaces: strpos str_replace |
Author: | Tony [ Wed Jul 25, 2007 11:04 am ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Combo points for when your function names accidentally conflict with some arbitrary package. PHP also tends to manifest horrible mess of a code. phpBB's index.php file has more lines of code than the entire codebase of the webapp I'm developing at work (Ruby/RoR) |
Author: | McKenzie [ Wed Jul 25, 2007 4:39 pm ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
Seems to me, if you are going to have a PHP section though, it should be to promote PHP, not simply tell people to develop in some other language. PHP is limited. But it is also very simple and widely used, and I would argue worth knowing how to use. |
Author: | rizzix [ Wed Jul 25, 2007 11:14 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Well it has some serious security issues. PHP makes it easy to write really bad code. There are other languages that are probably equal on grounds with PHP on language security, but at least they have some really solid frameworks that accounts for the flaws. PHP simply does not enforce any (secure) style of coding. It's very relaxed. While this is amazing for prototyping, it's bad for anything serious. Just look at our own compsci.ca, it runs on phpbb: a php base project. It has a large number of (potential) security flaws in it self. It is also difficult to improve or maintain it. You cannot blame the phpbb programmer alone on for the quality of software. In fact phpbb is probably(?) one of the better ones out there. Also, if one wishes to learn to develop good software, why not learn it, using language/frameworks that enforce good practises. PS: I totally agree with teaching them how to user it properly. That's exactly what md and all have tried (above). I'm just saying that there might be better alternatives to start with. After that one can always switch if they want. |
Author: | Aziz [ Thu Jul 26, 2007 9:40 am ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
McKenzie @ Wed Jul 25, 2007 5:39 pm wrote: Seems to me, if you are going to have a PHP section though, it should be to promote PHP, not simply tell people to develop in some other language.
wtd's "Why Java Sucks" topic comes to mind |
Author: | PaulButler [ Thu Jul 26, 2007 3:55 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
On the plus side, I just learned that PHP has anonymous (lambda) functions. They aren't very good, and you have to pass the code to create_function as a string, but PHP does have them. |
Author: | wtd [ Thu Jul 26, 2007 6:12 pm ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
Aziz @ Thu Jul 26, 2007 10:40 pm wrote: McKenzie @ Wed Jul 25, 2007 5:39 pm wrote: Seems to me, if you are going to have a PHP section though, it should be to promote PHP, not simply tell people to develop in some other language.
wtd's "Why Java Sucks" topic comes to mind You might also have noticed the Introduction to Java thread. I believe the best situation is balanced discussion. We should not simply tell people to use another programming language, but neither should we cheerlead for PHP. I think this thread fufills that goal. |
Author: | PaulButler [ Thu Jul 26, 2007 7:13 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Well, I'm not sure a balanced discussion is necessary when someone asks a basic question about the language. I shouldn't be the one to talk, because I contributed to the PHP bashing, but the thread had already gotten a bit off-topic at that point. |
Author: | rizzix [ Thu Jul 26, 2007 8:04 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Well, PaulButler I don't want to create a "Why PHP sucks" thread. I just thought to myself that maybe I could throw in my two cents. Heh. |
Author: | PaulButler [ Thu Jul 26, 2007 9:32 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
If you ever do start a "Why PHP sucks" thread, PM me so I can join in the fun . |
Author: | Aziz [ Fri Jul 27, 2007 8:03 am ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
wtd @ Thu Jul 26, 2007 7:12 pm wrote: Aziz @ Thu Jul 26, 2007 10:40 pm wrote: McKenzie @ Wed Jul 25, 2007 5:39 pm wrote: Seems to me, if you are going to have a PHP section though, it should be to promote PHP, not simply tell people to develop in some other language.
wtd's "Why Java Sucks" topic comes to mind You might also have noticed the Introduction to Java thread. I believe the best situation is balanced discussion. We should not simply tell people to use another programming language, but neither should we cheerlead for PHP. I think this thread fufills that goal. Indeed, even when wtd considers a language on par with feces, he still can still tell you you're doing it wrong >_> |
Author: | HyperFlexed [ Tue Aug 07, 2007 10:47 am ] |
Post subject: | Re: When $_GET['whatever'] has no value... |
wow. Never saw this coming. Hm, I'm developing a site with a login system, and I will eventually integrate it with something like phpBB. I might be interested in RoR, but integrating it with phpBB could get messy I think. Not sure. |
Author: | md [ Tue Aug 07, 2007 11:17 am ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Don't even think of using phpBB. There are much better solutions out there; ones which are actually well written and not full of security vulnerabilities. |
Author: | HyperFlexed [ Tue Aug 07, 2007 11:32 am ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
Well, Invision is nice... but $$$. |
Author: | md [ Tue Aug 07, 2007 11:21 pm ] |
Post subject: | RE:When $_GET[\'whatever\'] has no value... |
punBB is good too, though I hesitate to mention it only because I haven't used it in a long time. |