Jump to content

Very Idiotic Question


Tracekill

Recommended Posts

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.
Link to comment
Share on other sites

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 = <<<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]
Link to comment
Share on other sites

Ahh... you forgot to put a semi-colon after [code]$var1 = "LIBERTY"[/code]

Here is the fixed code: [code]<?php

$longstring = "";
$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]
Link to comment
Share on other sites

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. :)
Link to comment
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.