GB12 Posted April 4, 2011 Share Posted April 4, 2011 I am in a beginners php class. I am writing a function library right now. I keep getting an unexpected T_STRING error on line 44. Can anyone see an error in any of these lines? function getAirline ($destination) { if ($destination == "Barcelona") return Web Airlines; //This is line 44 elseif ($destination == "Cairo") return PHP Air; elseif ($destination == "Rome") return Air Java; elseif ($destination == "Santiago") return SQL Air; elseif ($destination == "Tokyo") return Object Oriented Airlines; } Link to comment https://forums.phpfreaks.com/topic/232674-keep-getting-an-unexpected-t_string-error/ Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 You need quotes around your return values. Link to comment https://forums.phpfreaks.com/topic/232674-keep-getting-an-unexpected-t_string-error/#findComment-1196712 Share on other sites More sharing options...
Stooney Posted April 4, 2011 Share Posted April 4, 2011 The issue is here return Web Airlines; You need to return a variable. Try this instead: return 'Web Airlines'; The same goes for every return you have there, surround the string with quotes as I did above. Link to comment https://forums.phpfreaks.com/topic/232674-keep-getting-an-unexpected-t_string-error/#findComment-1196714 Share on other sites More sharing options...
gristoi Posted April 4, 2011 Share Posted April 4, 2011 You need to return a string: return "Web Airlines" You were missing your speech marks Link to comment https://forums.phpfreaks.com/topic/232674-keep-getting-an-unexpected-t_string-error/#findComment-1196715 Share on other sites More sharing options...
GB12 Posted April 4, 2011 Author Share Posted April 4, 2011 Thanks guys. That fixed it. Sorry, I'm still a newbie, lol. Link to comment https://forums.phpfreaks.com/topic/232674-keep-getting-an-unexpected-t_string-error/#findComment-1196717 Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 Thanks guys. That fixed it. Sorry, I'm still a newbie, lol. No problem, we all start somewhere. In the future, please use tags around your code. Link to comment https://forums.phpfreaks.com/topic/232674-keep-getting-an-unexpected-t_string-error/#findComment-1196724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.