Tracekill Posted September 21, 2006 Share Posted September 21, 2006 Probably a very simple and idiotic question to ask but I'm trying to write a simple practice script to test out heredocs. I have this:[code]<?php$var1 = "LIBERTY"$longstring = <<<ENDSTRING No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, $var1, or property, without due process of law; nor shall private property be taken for public use, without just compensation. ENDSTRING; echo $longstring; ?>[/code]It gives me the error:[code]syntax error, unexpected T_VARIABLE[/code]Really sorry for wasting your time with such a simple question but I'm stuck, I thought I had everything right. Quote Link to comment https://forums.phpfreaks.com/topic/21561-very-idiotic-question/ Share on other sites More sharing options...
Daniel0 Posted September 21, 2006 Share Posted September 21, 2006 You have a whitespace before ENDSTRING; ;)It has to be the absolute ONLY thing on the entire line.You're not wasting our time and it is not an idiotic question. Everybody makes errors when they try to learn something new, and we are here to help people. Quote Link to comment https://forums.phpfreaks.com/topic/21561-very-idiotic-question/#findComment-96213 Share on other sites More sharing options...
Tracekill Posted September 21, 2006 Author Share Posted September 21, 2006 Wow thank you for your reply it was both helpful and kind.I had a feeling that was the problem but my editor wouldn't let me delete the space in front of it so I thought it was fine but that was just due to the fact that it was in debug mode. Anyway cleared out that space but getting the same error:[code]<?php$var1 = "LIBERTY"$longstring = <<<ENDSTRINGNo person shall be held to answer for a capital,or otherwise infamous crime,unless on a presentment or indictment of a Grand Jury,except in cases arising in the land or naval forces,or in the Militia,when in actual service in time of War or public danger;nor shall any person be subject for the sameoffence to be twice put in jeopardy oflife or limb; nor shall be compelled in anycriminal case to be a witness against himself,nor be deprived of life, $var1, or property,without due process of law; nor shall privateproperty be taken for public use, without justcompensation.ENDSTRING; echo $longstring; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21561-very-idiotic-question/#findComment-96220 Share on other sites More sharing options...
Daniel0 Posted September 21, 2006 Share Posted September 21, 2006 Ahh... you forgot to put a semi-colon after [code]$var1 = "LIBERTY"[/code]Here is the fixed code: [code]<?php$longstring = "";$var1 = "LIBERTY";$longstring = <<<ENDSTRINGNo person shall be held to answer for a capital,or otherwise infamous crime,unless on a presentment or indictment of a Grand Jury,except in cases arising in the land or naval forces,or in the Militia,when in actual service in time of War or public danger;nor shall any person be subject for the sameoffence to be twice put in jeopardy oflife or limb; nor shall be compelled in anycriminal case to be a witness against himself,nor be deprived of life, $var1, or property,without due process of law; nor shall privateproperty be taken for public use, without justcompensation.ENDSTRING; echo $longstring; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21561-very-idiotic-question/#findComment-96222 Share on other sites More sharing options...
Tracekill Posted September 21, 2006 Author Share Posted September 21, 2006 See? It was an idiotic problem. SO sorry to waste your time I should really have checked for that but the error return on the following line threw me off. Quote Link to comment https://forums.phpfreaks.com/topic/21561-very-idiotic-question/#findComment-96224 Share on other sites More sharing options...
Daniel0 Posted September 21, 2006 Share Posted September 21, 2006 No, it's just fine. If I thought it was waste of time I would not have replied at all.Let me instead tell you what the error means:[quote]syntax error, unexpected T_VARIABLE[/quote] means that there is a syntax error. It found a variable where it expected something else, in this case a semi-colon to end the definition of the variable $var1. :) Quote Link to comment https://forums.phpfreaks.com/topic/21561-very-idiotic-question/#findComment-96226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.