|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP Switch() Issue
Hello!
I have browsed the site a while for a solution to my problem but I have not been so lucky. Today I loaded Apache 2 and PHP5. I set up the config for apache and was able to successfully get a page to display With that I wanted to test my new found knowledge with the Switch() statement. So I grabbed this code from the offical php site, Whenever I run the php page, say switchtest.php?i=1 or switchtest.php?i=5555 , I always get back " i equals 0 ". I am confused as to why every switch I write / copy always gives me the first case, or the default case. (I tried another switch where all it would do is give me default.) Now I'm sure this is valid code, since it came from the source, so what sort of things outside of my php page could be the problem? Thanks very much for your reply. I think I'm up to 5hours on working with this problem. |
|
#2
|
|||
|
|||
|
RE: PHP Switch() Issue
The variable $i must be set someplace in the code prior to the switch(...) statement.
Putting ?i=somevalue on the end of the URL would only set the variable $i in your program if you had a statement like the following - $i = $_GET['i']; |
|
#3
|
|||
|
|||
|
RE: PHP Switch() Issue
Out of all the code I read and sample tutorials I never saw that line of code. Even in the "working" example pages I downloaded and tested, all of them failed. However it works perfectly now that I've added that code.
Its funny but I remember reading about the get and post commands but at the time didn't quite understand their importance. Thanks for the information! |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Installation > PHP Switch() Issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|