Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7821 > unrolled thread

HP syntax error, unexpected T_variable

Started by"Twayne" <nobody@devnull.spamcop.net>
First post2012-12-17 12:08 -0500
Last post2012-12-18 17:34 +0000
Articles 16 — 7 participants

Back to article view | Back to comp.lang.php


Contents

  HP syntax error, unexpected T_variable "Twayne" <nobody@devnull.spamcop.net> - 2012-12-17 12:08 -0500
    Re: HP syntax error, unexpected T_variable "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-17 18:19 +0100
      Re: HP syntax error, unexpected T_variable "Twayne" <nobody@devnull.spamcop.net> - 2012-12-17 12:44 -0500
        Re: HP syntax error, unexpected T_variable Denis McMahon <denismfmcmahon@gmail.com> - 2012-12-17 18:05 +0000
    Re: HP syntax error, unexpected T_variable The Natural Philosopher <tnp@invalid.invalid> - 2012-12-17 17:30 +0000
    Re: HP syntax error, unexpected T_variable Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-18 00:51 +0100
      Re: HP syntax error, unexpected T_variable Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-17 19:51 -0500
        Re: HP syntax error, unexpected T_variable "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-18 12:36 +0100
          Re: HP syntax error, unexpected T_variable Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-18 07:10 -0500
            Re: HP syntax error, unexpected T_variable "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-18 14:11 +0100
              Re: HP syntax error, unexpected T_variable Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-18 11:50 -0500
                Re: HP syntax error, unexpected T_variable Adam Harvey <usenet@adamharvey.name> - 2012-12-19 02:02 +0000
                  Re: HP syntax error, unexpected T_variable Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-18 21:23 -0500
                  Re: HP syntax error, unexpected T_variable "Twayne" <nobody@devnull.spamcop.net> - 2012-12-18 21:41 -0500
      RESOLVED! Re: HP syntax error, unexpected T_variable "Twayne" <nobody@devnull.spamcop.net> - 2012-12-17 20:56 -0500
        Re: RESOLVED! Re: HP syntax error, unexpected T_variable Denis McMahon <denismfmcmahon@gmail.com> - 2012-12-18 17:34 +0000

#7821 — HP syntax error, unexpected T_variable

From"Twayne" <nobody@devnull.spamcop.net>
Date2012-12-17 12:08 -0500
SubjectHP syntax error, unexpected T_variable
Message-ID<kanjie$4pm$1@speranza.aioe.org>
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@example.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@example.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@twaynesdomain.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. 

[toc] | [next] | [standalone]


#7822

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2012-12-17 18:19 +0100
Message-ID<aj92hoFhv6sU1@mid.uni-berlin.de>
In reply to#7821
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@example.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@example.com';
php > if (isset( $_POST['email'])) { $to_1 = $_POST['email']; $to_2 = 'me@example.org';}
php > echo "I send mails to $to_1 and $to_2 \n";
I send mails to cc@example.com and me@example.org


/Str.



[toc] | [prev] | [next] | [standalone]


#7824

From"Twayne" <nobody@devnull.spamcop.net>
Date2012-12-17 12:44 -0500
Message-ID<kanlmv$asi$1@speranza.aioe.org>
In reply to#7822
In news:aj92hoFhv6sU1@mid.uni-berlin.de,
M. Strobel <sorry_no_mail_here@nowhere.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@example.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@example.com';
> php > if (isset( $_POST['email'])) { $to_1 =
> $_POST['email']; $to_2 = 'me@example.org';} php > echo "I
> send mails to $to_1 and $to_2 \n";
> I send mails to cc@example.com and me@example.org
>
>
> /Str.


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

Twayne` 

[toc] | [prev] | [next] | [standalone]


#7825

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2012-12-17 18:05 +0000
Message-ID<kanmta$7bo$2@dont-email.me>
In reply to#7824
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

[toc] | [prev] | [next] | [standalone]


#7823

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-12-17 17:30 +0000
Message-ID<kankqv$4oa$2@news.albasani.net>
In reply to#7821
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@example.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@example.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@twaynesdomain.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.

[toc] | [prev] | [next] | [standalone]


#7828

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-12-18 00:51 +0100
Message-ID<1444038.JEF8UCOMkY@PointedEars.de>
In reply to#7821
Twayne wrote:

> […]
>    PHP 5.3.5 on XP Pro SP3+, Apache 2.2 local server.
> 
> ------------------------
> 
> <?php
> if(isset($_POST['email'])) {
> 
>   $email_to=me@example.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@news.demon.co.uk>

[toc] | [prev] | [next] | [standalone]


#7830

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-12-17 19:51 -0500
Message-ID<kaoenk$9ef$1@dont-email.me>
In reply to#7828
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@example.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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#7833

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2012-12-18 12:36 +0100
Message-ID<ajb2pgF16unU1@mid.uni-berlin.de>
In reply to#7830
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@example.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.

[toc] | [prev] | [next] | [standalone]


#7834

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-12-18 07:10 -0500
Message-ID<kapmf8$bg9$1@dont-email.me>
In reply to#7833
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@example.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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#7835

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2012-12-18 14:11 +0100
Message-ID<ajb8btF2f7eU1@mid.uni-berlin.de>
In reply to#7834
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@example.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.

[toc] | [prev] | [next] | [standalone]


#7838

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-12-18 11:50 -0500
Message-ID<kaq6sc$ilb$1@dont-email.me>
In reply to#7835
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@example.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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#7846

FromAdam Harvey <usenet@adamharvey.name>
Date2012-12-19 02:02 +0000
Message-ID<kar777$24g$1@dont-email.me>
In reply to#7838
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

[toc] | [prev] | [next] | [standalone]


#7848

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-12-18 21:23 -0500
Message-ID<kar8ei$8t6$1@dont-email.me>
In reply to#7846
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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#7849

From"Twayne" <nobody@devnull.spamcop.net>
Date2012-12-18 21:41 -0500
Message-ID<kar9h0$6e7$1@speranza.aioe.org>
In reply to#7846
In news:kar777$24g$1@dont-email.me,
Adam Harvey <usenet@adamharvey.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`

[toc] | [prev] | [next] | [standalone]


#7837 — RESOLVED! Re: HP syntax error, unexpected T_variable

From"Twayne" <nobody@devnull.spamcop.net>
Date2012-12-17 20:56 -0500
SubjectRESOLVED! Re: HP syntax error, unexpected T_variable
Message-ID<kaq1vs$2kb$2@speranza.aioe.org>
In reply to#7828
In news:1444038.JEF8UCOMkY@PointedEars.de,
Thomas 'PointedEars' Lahn <PointedEars@web.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@example.com;
>              ^             ^
>> /*
>> Parse error: syntax error, unexpected T_VARIABLE in
>> C:\xampp\htdocs\send.php on line 5
>> */
>> ...
...






[toc] | [prev] | [next] | [standalone]


#7839 — Re: RESOLVED! Re: HP syntax error, unexpected T_variable

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2012-12-18 17:34 +0000
SubjectRe: RESOLVED! Re: HP syntax error, unexpected T_variable
Message-ID<kaq9eh$56m$1@dont-email.me>
In reply to#7837
On Mon, 17 Dec 2012 20:56:59 -0500, Twayne wrote:

> In news:1444038.JEF8UCOMkY@PointedEars.de,
> Thomas 'PointedEars' Lahn <PointedEars@web.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@example.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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web