FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » HP syntax error, unexpected T_variable
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
HP syntax error, unexpected T_variable [message #179889] Mon, 17 December 2012 17:08 Go to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
I'm still fighting the error message below over two days now. I'm back again
hopefully
simplifying my question to get more answers. So far I've had no hint what
the syntax error is. As a neophyte I'm trying to work down thru one problem
at a time so it's a learning experience, too. I've looked at several other
scripts and they seem to do the same thing I'm doing.
PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.

------------------------

<?php
if(isset($_POST['email'])) {

$email_to=me(at)example(dot)com;
/*
Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\send.php
on line 5
*/
....
?>
----------------------------

I've also tried it with single/double quotes; no help. I just can NOT figure
out what the Syntax error would be.

If I comment out that line, I get more such messages at other places in the
script so I'm doing something stupid here, I know! WHAT is the syntax
problem with $email_to="me(at)example(dot)com? (My own address removed)

For those who may wish to see the complete code of send.php, here it is:
==============

<?php
if(isset($_POST['email'])) {
$email="twayne(at)twaynesdomain(dot)com";
}
/*
Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\send.php
on line 5
*/


$subject = 'From the Web Site';
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with // the
form you submitted. ";
}

// validation expected data exists
if(!isset($_POST['email']) ||
!isset($_POST['subject']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form
you submitted.');
}


$email = $_POST {'email']; //required
$subject = $_POST['subject']; // required
$comments = $_POST['comments']; // required
}

echo '$email';
echo '$subject';
echo '$comments';




$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be
valid.<br />'};
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$email) {
$error_message .= 'The Email Address you entered does not appear to be
valid.<br />'};
}
if(!preg_match($string_exp,$subject)) {
$error_message .= 'The Subject you entered does not appear to be
valid.<br />'};
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be
valid.<br />'};
}

if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "Email: ".clean_string($email_from)."\n";
$subject .= 'subject: " . .clean_string($subject). "/n?;
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.
*/

<?php
}
?>
============

HTH,

Twayne`
--
Life is the only real counselor; wisdom unfiltered
through personal experience does not become a
part of the moral tissue.
Re: HP syntax error, unexpected T_variable [message #179890 is a reply to message #179889] Mon, 17 December 2012 17:19 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 17.12.2012 18:08, schrieb Twayne:
> I'm still fighting the error message below over two days now. I'm back again
> hopefully
> simplifying my question to get more answers. So far I've had no hint what
> the syntax error is. As a neophyte I'm trying to work down thru one problem
> at a time so it's a learning experience, too. I've looked at several other
> scripts and they seem to do the same thing I'm doing.
> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>
> ------------------------
>
> <?php
> if(isset($_POST['email'])) {
>
> $email_to=me(at)example(dot)com;
> /*
> Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\send.php
> on line 5
> */
> ...
> ?>
> ----------------------------

There must be something wrong with your installation. Or you are execting a different
php file than you think.

strobel@s114-intel:~> php -a
Interactive shell

php > $_POST['email']= 'cc(at)example(dot)com';
php > if (isset( $_POST['email'])) { $to_1 = $_POST['email']; $to_2 = 'me(at)example(dot)org';}
php > echo "I send mails to $to_1 and $to_2 \n";
I send mails to cc(at)example(dot)com and me(at)example(dot)org


/Str.
Re: HP syntax error, unexpected T_variable [message #179891 is a reply to message #179889] Mon, 17 December 2012 17:30 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 17/12/12 17:08, Twayne wrote:
> I'm still fighting the error message below over two days now. I'm back again
> hopefully
> simplifying my question to get more answers. So far I've had no hint what
> the syntax error is. As a neophyte I'm trying to work down thru one problem
> at a time so it's a learning experience, too. I've looked at several other
> scripts and they seem to do the same thing I'm doing.
> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>
> ------------------------
>
> <?php
> if(isset($_POST['email'])) {
>
> $email_to=me(at)example(dot)com;
> /*
> Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\send.php
> on line 5
> */
> ...
> ?>
> ----------------------------
>
> I've also tried it with single/double quotes; no help. I just can NOT figure
> out what the Syntax error would be.
>
> If I comment out that line, I get more such messages at other places in the
> script so I'm doing something stupid here, I know! WHAT is the syntax
> problem with $email_to="me(at)example(dot)com? (My own address removed)
>
> For those who may wish to see the complete code of send.php, here it is:
> ==============
>
> <?php
> if(isset($_POST['email'])) {
> $email="twayne(at)twaynesdomain(dot)com";
> }
> /*
> Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\send.php
> on line 5
> */
>
>
> $subject = 'From the Web Site';
> function died($error) {
> // your error code can go here
> echo "We are very sorry, but there were error(s) found with // the
> form you submitted. ";
> }
>
> // validation expected data exists
> if(!isset($_POST['email']) ||
> !isset($_POST['subject']) ||
> !isset($_POST['comments'])) {
> died('We are sorry, but there appears to be a problem with the form
> you submitted.');
> }
>
>
> $email = $_POST {'email']; //required

*****************one syntax error right there


> $subject = $_POST['subject']; // required
> $comments = $_POST['comments']; // required
> }
>
> echo '$email';
> echo '$subject';
> echo '$comments';
>
>
>
>
> $error_message = "";
> $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
> if(!preg_match($email_exp,$email_from)) {
> $error_message .= 'The Email Address you entered does not appear to be
> valid.<br />'};
> }
> $string_exp = "/^[A-Za-z .'-]+$/";
> if(!preg_match($string_exp,$email) {
> $error_message .= 'The Email Address you entered does not appear to be
> valid.<br />'};
> }
> if(!preg_match($string_exp,$subject)) {
> $error_message .= 'The Subject you entered does not appear to be
> valid.<br />'};
> }
> if(strlen($comments) < 2) {
> $error_message .= 'The Comments you entered do not appear to be
> valid.<br />'};
> }
>
> if(strlen($error_message) > 0) {
> died($error_message);
> }
> $email_message = "Form details below.\n\n";
>
> function clean_string($string) {
> $bad = array("content-type","bcc:","to:","cc:","href");
> return str_replace($bad,"",$string);
> }
>
> $email_message .= "Email: ".clean_string($email_from)."\n";
> $subject .= 'subject: " . .clean_string($subject). "/n?;
> $email_message .= "Comments: ".clean_string($comments)."\n";
>
>
> // create email headers
> $headers = 'From: '.$email_from."\r\n".
> 'Reply-To: '.$email_from."\r\n" .
> 'X-Mailer: PHP/' . phpversion();
> @mail($email_to, $email_subject, $email_message, $headers);
> ?>
>
> <!-- include your own success html here -->
>
> Thank you for contacting us. We will be in touch with you very soon.
> */
>
> <?php
> }
> ?>
> ============
>
> HTH,
>
> Twayne`
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: HP syntax error, unexpected T_variable [message #179892 is a reply to message #179890] Mon, 17 December 2012 17:44 Go to previous messageGo to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:aj92hoFhv6sU1(at)mid(dot)uni-berlin(dot)de,
M. Strobel <sorry_no_mail_here(at)nowhere(dot)dee> typed:
> Am 17.12.2012 18:08, schrieb Twayne:
>> I'm still fighting the error message below over two days
>> now. I'm back again hopefully
>> simplifying my question to get more answers. So far I've
>> had no hint what the syntax error is. As a neophyte I'm
>> trying to work down thru one problem at a time so it's a
>> learning experience, too. I've looked at several other
>> scripts and they seem to do the same thing I'm doing.
>> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>
>> ------------------------
>>
>> <?php
>> if(isset($_POST['email'])) {
>>
>> $email_to=me(at)example(dot)com;
>> /*
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\xampp\htdocs\send.php on line 5
>> */
>> ...
>>>
>> ----------------------------
>
> There must be something wrong with your installation. Or
> you are execting a different php file than you think.

If there's anything wrong with my installation I'm not aware of it. I've
gone thru php.ini pretty closely and the XAMPP conf files and AFAICT all is
OK.
Every other .php I have played with works, including phpinfo and several
other stubs I've played with.

No, I'm not getting the wrong file. It only exists in and is saved directly
to htdocs.

I use NotePro to develop my code as it has an automatic click where all
it takes is a click to send the file in htdocs to my local server. It also
has a great clip library for PHP plus I made one of my own to make things
easier to find.

And I use NoteTab for highlghting the text, etc. when I have to
troubleshoot. Maybe I will look into a legit IDE and see if that helps with
stuff like this.
>
> strobel@s114-intel:~> php -a
> Interactive shell
>
> php > $_POST['email']= 'cc(at)example(dot)com';
> php > if (isset( $_POST['email'])) { $to_1 =
> $_POST['email']; $to_2 = 'me(at)example(dot)org';} php > echo "I
> send mails to $to_1 and $to_2 \n";
> I send mails to cc(at)example(dot)com and me(at)example(dot)org
>
>
> /Str.


that might help; I'll dig more into it. Thanks.

Twayne`
Re: HP syntax error, unexpected T_variable [message #179893 is a reply to message #179892] Mon, 17 December 2012 18:05 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 17 Dec 2012 12:44:57 -0500, Twayne wrote:

> that might help; I'll dig more into it. Thanks.

What will help will doing what Jerry said to do in the bsame thread that
you started in the other newsgroup.

Put the string literal in quotes.

For someone who just claimed to have been programming in php since 1991,
you sure have an amazing lack of understanding about how it handles
string literals.

Rgds

Denis McMahon
Re: HP syntax error, unexpected T_variable [message #179896 is a reply to message #179889] Mon, 17 December 2012 23:51 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Twayne wrote:

> […]
> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>
> ------------------------
>
> <?php
> if(isset($_POST['email'])) {
>
> $email_to=me(at)example(dot)com;
^ ^
> /*
> Parse error: syntax error, unexpected T_VARIABLE in
> C:\xampp\htdocs\send.php on line 5
> */
> ...
> ?>
^^
Superfluous and error-prone at the end of a file. Also, there should be a
“}” before it to end the block of the “if” statement.

> ----------------------------
>
> I've also tried it with single/double quotes; no help.

You probably put them in the wrong places or not in pairs.

> I just can NOT figure out what the Syntax error would be.

RTFM before coding might just help.

> [lots of uncommented LOCs]

You can't be serious.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
Re: HP syntax error, unexpected T_variable [message #179898 is a reply to message #179896] Tue, 18 December 2012 00:51 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/17/2012 6:51 PM, Thomas 'PointedEars' Lahn wrote:
> Twayne wrote:
>
>> […]
>> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>
>> ------------------------
>>
>> <?php
>> if(isset($_POST['email'])) {
>>
>> $email_to=me(at)example(dot)com;
> ^ ^
>> /*
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\xampp\htdocs\send.php on line 5
>> */
>> ...
>> ?>
> ^^
> Superfluous and error-prone at the end of a file. Also, there should be a
> “}” before it to end the block of the “if” statement.
>

Maybe you consider it superfluous, but GOOD programmer close their code
at the end. Of course, we know YOU don't.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: HP syntax error, unexpected T_variable [message #179901 is a reply to message #179898] Tue, 18 December 2012 11:36 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 18.12.2012 01:51, schrieb Jerry Stuckle:
> On 12/17/2012 6:51 PM, Thomas 'PointedEars' Lahn wrote:
>> Twayne wrote:
>>
>>> […]
>>> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>>
>>> ------------------------
>>>
>>> <?php
>>> if(isset($_POST['email'])) {
>>>
>>> $email_to=me(at)example(dot)com;
>> ^ ^
>>> /*
>>> Parse error: syntax error, unexpected T_VARIABLE in
>>> C:\xampp\htdocs\send.php on line 5
>>> */
>>> ...
>>> ?>
>> ^^
>> Superfluous and error-prone at the end of a file. Also, there should be a
>> “}” before it to end the block of the “if” statement.
>>
>
> Maybe you consider it superfluous, but GOOD programmer close their code at the end.
> Of course, we know YOU don't.
>

Zend Framework does not use ?> in PHP only files. Just checked.

/Str.
Re: HP syntax error, unexpected T_variable [message #179902 is a reply to message #179901] Tue, 18 December 2012 12:10 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/18/2012 6:36 AM, M. Strobel wrote:
> Am 18.12.2012 01:51, schrieb Jerry Stuckle:
>> On 12/17/2012 6:51 PM, Thomas 'PointedEars' Lahn wrote:
>>> Twayne wrote:
>>>
>>>> […]
>>>> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>>>
>>>> ------------------------
>>>>
>>>> <?php
>>>> if(isset($_POST['email'])) {
>>>>
>>>> $email_to=me(at)example(dot)com;
>>> ^ ^
>>>> /*
>>>> Parse error: syntax error, unexpected T_VARIABLE in
>>>> C:\xampp\htdocs\send.php on line 5
>>>> */
>>>> ...
>>>> ?>
>>> ^^
>>> Superfluous and error-prone at the end of a file. Also, there should be a
>>> “}” before it to end the block of the “if” statement.
>>>
>>
>> Maybe you consider it superfluous, but GOOD programmer close their code at the end.
>> Of course, we know YOU don't.
>>
>
> Zend Framework does not use ?> in PHP only files. Just checked.
>
> /Str.
>

I rest my case.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: HP syntax error, unexpected T_variable [message #179903 is a reply to message #179902] Tue, 18 December 2012 13:11 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 18.12.2012 13:10, schrieb Jerry Stuckle:
> On 12/18/2012 6:36 AM, M. Strobel wrote:
>> Am 18.12.2012 01:51, schrieb Jerry Stuckle:
>>> On 12/17/2012 6:51 PM, Thomas 'PointedEars' Lahn wrote:
>>>> Twayne wrote:
>>>>
>>>> > […]
>>>> > PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>>> >
>>>> > ------------------------
>>>> >
>>>> > <?php
>>>> > if(isset($_POST['email'])) {
>>>> >
>>>> > $email_to=me(at)example(dot)com;
>>>> ^ ^
>>>> > /*
>>>> > Parse error: syntax error, unexpected T_VARIABLE in
>>>> > C:\xampp\htdocs\send.php on line 5
>>>> > */
>>>> > ...
>>>> > ?>
>>>> ^^
>>>> Superfluous and error-prone at the end of a file. Also, there should be a
>>>> “}” before it to end the block of the “if” statement.
>>>>
>>>
>>> Maybe you consider it superfluous, but GOOD programmer close their code at the end.
>>> Of course, we know YOU don't.
>>>
>>
>> Zend Framework does not use ?> in PHP only files. Just checked.
>>
>> /Str.
>>
>
> I rest my case.

Just for the many readers,

the problem with the closing tag is, that you get difficult to control newlines and
spaces in the output.

This is hardly noticeable in HTML, but a big problem when serving binary files.

/Str.
RESOLVED! Re: HP syntax error, unexpected T_variable [message #179905 is a reply to message #179896] Tue, 18 December 2012 01:56 Go to previous messageGo to next message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:1444038(dot)JEF8UCOMkY(at)PointedEars(dot)de,
Thomas 'PointedEars' Lahn <PointedEars(at)web(dot)de> typed:
> Twayne wrote:
>
>> [b&]
>> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>
>> ------------------------
>>
>> <?php
>> if(isset($_POST['email'])) {
>>
>> $email_to=me(at)example(dot)com;
> ^ ^
>> /*
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\xampp\htdocs\send.php on line 5
>> */
>> ...
....
Re: HP syntax error, unexpected T_variable [message #179906 is a reply to message #179903] Tue, 18 December 2012 16:50 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/18/2012 8:11 AM, M. Strobel wrote:
> Am 18.12.2012 13:10, schrieb Jerry Stuckle:
>> On 12/18/2012 6:36 AM, M. Strobel wrote:
>>> Am 18.12.2012 01:51, schrieb Jerry Stuckle:
>>>> On 12/17/2012 6:51 PM, Thomas 'PointedEars' Lahn wrote:
>>>> > Twayne wrote:
>>>> >
>>>> >> […]
>>>> >> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>>> >>
>>>> >> ------------------------
>>>> >>
>>>> >> <?php
>>>> >> if(isset($_POST['email'])) {
>>>> >>
>>>> >> $email_to=me(at)example(dot)com;
>>>> > ^ ^
>>>> >> /*
>>>> >> Parse error: syntax error, unexpected T_VARIABLE in
>>>> >> C:\xampp\htdocs\send.php on line 5
>>>> >> */
>>>> >> ...
>>>> >> ?>
>>>> > ^^
>>>> > Superfluous and error-prone at the end of a file. Also, there should be a
>>>> > “}” before it to end the block of the “if” statement.
>>>> >
>>>>
>>>> Maybe you consider it superfluous, but GOOD programmer close their code at the end.
>>>> Of course, we know YOU don't.
>>>>
>>>
>>> Zend Framework does not use ?> in PHP only files. Just checked.
>>>
>>> /Str.
>>>
>>
>> I rest my case.
>
> Just for the many readers,
>
> the problem with the closing tag is, that you get difficult to control newlines and
> spaces in the output.
>
> This is hardly noticeable in HTML, but a big problem when serving binary files.
>
> /Str.
>
>

It is not a problem for good programmers. They know not to place
newline characters after the ?>. Additionally, if one sneaks in, the
error message generated is QUITE clear.

And BTW - PHP scripts are NOT "binary files".

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: RESOLVED! Re: HP syntax error, unexpected T_variable [message #179907 is a reply to message #179905] Tue, 18 December 2012 17:34 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 17 Dec 2012 20:56:59 -0500, Twayne wrote:

> In news:1444038(dot)JEF8UCOMkY(at)PointedEars(dot)de,
> Thomas 'PointedEars' Lahn <PointedEars(at)web(dot)de> typed:
>> Twayne wrote:
>>
>>> [b&]
>>> PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
>>>
>>> ------------------------
>>>
>>> <?php if(isset($_POST['email'])) {
>>>
>>> $email_to=me(at)example(dot)com;
>> ^ ^
>>> /*
>>> Parse error: syntax error, unexpected T_VARIABLE in
>>> C:\xampp\htdocs\send.php on line 5 */
>>> ...
> ...

So what was the solution then?

Rgds

Denis McMahon




--
/home/denis/sig.txt
Re: HP syntax error, unexpected T_variable [message #179914 is a reply to message #179906] Wed, 19 December 2012 02:02 Go to previous messageGo to next message
Adam Harvey is currently offline  Adam Harvey
Messages: 25
Registered: September 2010
Karma: 0
Junior Member
On Tue, 18 Dec 2012 11:50:11 -0500, Jerry Stuckle wrote:

> On 12/18/2012 8:11 AM, M. Strobel wrote:
>> Just for the many readers,
>>
>> the problem with the closing tag is, that you get difficult to control
>> newlines and spaces in the output.
>>
>> This is hardly noticeable in HTML, but a big problem when serving
>> binary files.
>>
>> /Str.
>>
>>
>>
> It is not a problem for good programmers. They know not to place
> newline characters after the ?>. Additionally, if one sneaks in, the
> error message generated is QUITE clear.
>
> And BTW - PHP scripts are NOT "binary files".

Of course not, but consider the case where you're outputting a JPEG image
from a PHP script: there's not necessarily an obvious error message if
there's trailing whitespace after a ?> (since PHP doesn't care), but the
image will still be broken nonetheless.

Most modern PHP coding standards I know of now recommend against the ?>
for that reason. I personally agree.

Of course, coding standards in general tend to be a bit of a religious
issue!

Adam
Re: HP syntax error, unexpected T_variable [message #179916 is a reply to message #179914] Wed, 19 December 2012 02:23 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/18/2012 9:02 PM, Adam Harvey wrote:
> On Tue, 18 Dec 2012 11:50:11 -0500, Jerry Stuckle wrote:
>
>> On 12/18/2012 8:11 AM, M. Strobel wrote:
>>> Just for the many readers,
>>>
>>> the problem with the closing tag is, that you get difficult to control
>>> newlines and spaces in the output.
>>>
>>> This is hardly noticeable in HTML, but a big problem when serving
>>> binary files.
>>>
>>> /Str.
>>>
>>>
>>>
>> It is not a problem for good programmers. They know not to place
>> newline characters after the ?>. Additionally, if one sneaks in, the
>> error message generated is QUITE clear.
>>
>> And BTW - PHP scripts are NOT "binary files".
>
> Of course not, but consider the case where you're outputting a JPEG image
> from a PHP script: there's not necessarily an obvious error message if
> there's trailing whitespace after a ?> (since PHP doesn't care), but the
> image will still be broken nonetheless.
>
> Most modern PHP coding standards I know of now recommend against the ?>
> for that reason. I personally agree.
>
> Of course, coding standards in general tend to be a bit of a religious
> issue!
>
> Adam
>

Yes, PHP is well known for sloppy programmers - more so than any other
language around.

As for your jpeg - it's still a simple problem if your error logging is
set up properly in your development system. And if your development
system correctly duplicates your production system, if it works on the
development system, it will work on the production system.

I have several development systems set up here (for different clients
who have different needs). I have never had a problem with code working
on the development system and not working on the production one.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: HP syntax error, unexpected T_variable [message #179917 is a reply to message #179914] Wed, 19 December 2012 02:41 Go to previous message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:kar777$24g$1(at)dont-email(dot)me,
Adam Harvey <usenet(at)adamharvey(dot)name> typed:
> On Tue, 18 Dec 2012 11:50:11 -0500, Jerry Stuckle wrote:
>
>> On 12/18/2012 8:11 AM, M. Strobel wrote:
>>> Just for the many readers,
>>>
>>> the problem with the closing tag is, that you get
>>> difficult to control newlines and spaces in the output.
>>>
>>> This is hardly noticeable in HTML, but a big problem
>>> when serving binary files.
>>>
>>> /Str.
>>>
>>>
>>>
>> It is not a problem for good programmers. They know not
>> to place newline characters after the ?>. Additionally,
>> if one sneaks in, the error message generated is QUITE
>> clear.
>>
>> And BTW - PHP scripts are NOT "binary files".
>
> Of course not, but consider the case where you're
> outputting a JPEG image from a PHP script: there's not
> necessarily an obvious error message if there's trailing
> whitespace after a ?> (since PHP doesn't care), but the
> image will still be broken nonetheless.
>
> Most modern PHP coding standards I know of now recommend
> against the ?> for that reason. I personally agree.
>
> Of course, coding standards in general tend to be a bit
> of a religious issue!
>
> Adam

You're right there, Adam. I don't use that sort of tag/s so no big deal.
IIRC I set the server & .ini's to accept it, but I never used it. If it was
in my code somewhere, that was another stoopid move on my part!
Important thing is, I've got it fixed now.

HTH,

Twayne`
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Gettting values from URL in PHP 5.4
Next Topic: passing values into javascript
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 15:38:33 GMT 2024

Total time taken to generate the page: 0.02414 seconds