Jump to content

Recommended Posts

Is there a limit on how many else if statement you can use?

 

I am getting a PHP Parse error: parse error, unexpected T_CLASS about the fifth one down.

 

if($productform == 'Shinform')
$productselect = Shin;

elseif($productform == 'Littleform')
$productselect = Little;

elseif($productform == 'Manform')
$productselect = Man;

elseif($productform == 'Smithform')
$productselect = Smith;

elseif ($productform == 'Classform')
$productselect = Class;

elseif($productform == 'OregonOform')
$productselect = OregonO;

elseif($productform == 'OregonFform')
$productselect = OregonF;

elseif($productform == 'Troyform')
$productselect = Troy;

elseif($productform == 'Whiteform')
$productselect = White;

elseif($productform == 'Trenchform')
$productselect = Trench;

else
echo $URL="http://www.mysite.com/nodealerselect.html";
header ("Location: $URL");

Link to comment
https://forums.phpfreaks.com/topic/48515-solved-else-if/
Share on other sites

Easier and neater option would be to use Swith/case:
[code]
switch($productform){

case "Shinform":
$productselect = "Shin";
break;

case "Littleform":
$productselect = "Little";
break;

default:
echo $URL="http://www.mysite.com/nodealerselect.html";
header ("Location: $URL");
break;


}
etc etc

 

If others find the need to correct me please do so, have not used switch case in a while...[/code]

Link to comment
https://forums.phpfreaks.com/topic/48515-solved-else-if/#findComment-237341
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.