WHAT in Heaven's name is a "T_STRING?" Nowhere do I see a definition of T_STRING, or why it is called T_something.

From what I've been able to piece together, it might be an unquoted string.

I have a

Parse error: syntax error, unexpected T_STRING in /home/xxxxxxxx/public_html/include/mmeetingDate.php on line 10

Since today is Saturday, the if statement dealing with Saturday is being run, and that includes the "goto report;" on line 10:

Oops, the code I was about to display did not include the definition of variable $dn, so I re-edited, adding the code that defines $dn, and put it up on my other site.Now the same error occurs on the same line of code, at Line 50.

Here is the front part of my code:

<?php function meetingDate($day = NULL, $week = NULL, $m = NULL, $y = NULL) {
$x = 0;
 // $dn is Day Number:
    if ((is_string($day))&&($day == 'sun')) {$dn = 1; }
elseif ((is_string($day))&&($day == 'mon')) {$dn = 2; }
elseif ((is_string($day))&&($day == 'tue')) {$dn = 3; }
elseif ((is_string($day))&&($day == 'wed')) {$dn = 4; }
elseif ((is_string($day))&&($day == 'thu')) {$dn = 5; }
elseif ((is_string($day))&&($day == 'fri')) {$dn = 6; }
elseif ((is_string($day))&&($day == 'sat')) {$dn = 7; }
else { # Output HTML: ?>
<p class = "hilite">You have entered:&nbsp; <?php echo $day?><br />
The first argument must be one of <br />
<strong>'sun' 'mon' 'tue' 'wed' 'thu' 'fri' 'sat'</strong></p>
<?php # Resume PHP
$x = 1; }

// Test second argument
if ((is_int($week))&&(($week < 1) or ($week > 5))) { # Output HTML: ?>
<p class = "hilite">You have entered:&nbsp; <?php echo $week?>.<br />
The second argument must be one of <br />
<strong>1 2 3 4 5</strong></p>
<?php # Resume PHP
$x = 1; }

# Test third argument
if ((is_int($m))&&(($m < 1) or ($m > 12))) { # Output HTML: ?>
<p class = "hilite">You've entered:&nbsp; <?php echo $m?>.<br />
The third argument must be one between, inclusive <br />
<strong>1 through 12</strong></p>
<?php # Resume PHP
 $x = 1; }

# Test fourth argument
if ((is_float($y))&&(($y < 1970) or ($y > 2037))) { # Output HTML: ?>
<p class = "hilite">You'."'".'ve entered:&nbsp; '.$m.'<br />'."\n".'The fourth argument must be a 4-digit year from 1970 to 2037. <br />
<?php # Resume PHP
$x = 1; }
if ($x == 1 ) {$x = 0; return; }

// The function passed the invalid input test.

$firstofMonth = mktime(0, 0, 0, $m, 1, $y); // UNIX timestamp
$fdd = date('j',$firstofMonth); 
$fd = date('w',$firstofMonth);
// Get the day of the week numerically from our timestamp, $fd for First Day
// SAT
if ($fd == 6) 	{
$dn = $dn -7;
goto report;       // Line 50
		}
// FRI
if ($fd == 5) 	{
$dn = $dn -6;
goto report;
		}
// THU
if ($fd == 4) 	{
$dn = $dn -5;
goto report;
		}
// WED
if ($fd == 3) 	{
$dn = $dn -4;
goto report;
		}
// TUE
if ($fd == 2) 	{
$dn = $dn -3;
goto report;
		}
// MON
if ($fd == 1) 	{
$dn = $dn -2;
goto report;
		}
// SUN
if ($fd == 0) 	{
$dn = $dn -1;
goto report;
		}

report:
?>

I run XAMPP for Linux 1.7.4 and PHP 5.3.5
Free web site Apache 2 and PHP 5.2*
Paid web site Apache 2 and PHP 5.8.8

Both web sites throw the error, while the code runs just perfectly at home!

Internet must be down.....

I remember using # comment for Python have never tried that for PHP.
BTTT,
You have mixed HTML and PHP to a point f confusing me, cant help with that. If you need to print something like for use HEREDOC syntax. And goto? Can't beilieve it!

here is clean way of adding html in PHP

$form = <<<EOT
<form action={$_SERVER["PHP_SELF"]} method="post" enctype="multipart/form-data">
    <label for="file">Select File...</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
</form>

EOT;
echo $form;

First some comments about the three types of comments allowed in PHP:
Both the double-slash and the pound sign are acceptable one-line comments, requiring one at the start of each line of comments.

I also included a bunch of code commented-out in a multi-line comment. I use all of these in my current project:

<?php
# # # # # # # # # # # # # #
# Top descriptive heading #
# # # # # # # # # # # # # #

// echo "Hello world"; 

# echo " Hello again!";

/*
Multi-line comment
if ( 1 < 2 ) { echo "1 is less than 2.."; }
if ( 2 < 1 ) { echo " 2 is less than 1."; }
All of this has been commented-out.
*/
echo "This shows up as output on your screen!";
?>

Also, I jumped out of PHP several times in my code to output plain HTML. There were a lot of if conditions and if they were met there was a paragraph printed.

Believe me, it simplified the code a whole lot when I did that as opposed to trying to echo paragraphs with output containing both double quotes, single quotes and PHP variable values being included in the output.

<?php
// I did in PHP:

if $dn == 9 { ?>
<!-- Out of PHP, though I made this 
a PHP comment not HTML comment -->:
<p> This HTML prints</p>
<?php // Resume PHP:
}

My issue with my code was not resolved until I got rid of the label, even after I got rid of the goto-laden if block.

I have to agree that switch is better looking code, using break to exit the switch.

The code below is exact replica, including the multi-line comment surrounding the if block as it appears in my working script.

I found some interesting comments about goto, and apparently it's not widely supported.

Here is the replacement block of code:

?php
// Get the day of the week numerically from our timestamp, $fd for First Day
switch ($fd) {
    case 6: // SAT
        $dn = $dn -7;
        break;
    case 5: // FRI
        $dn = $dn -6;
        break;
    case 4: // THU
        $dn = $dn -5;
        break;
    case 3: // WED
        $dn = $dn -4;
        break;
    case 2: // TUE
        $dn = $dn -3;
        break;
    case 1: // MON
        $dn = $dn -2;
        break;
    case 0: // SUN
        $dn = $dn -1;
        break;
}
/* Switch Replacing this code:
// SAT
if ($fd == 6) 	{
$dn = $dn -7;
goto report;
		}
// FRI
if ($fd == 5) 	{
$dn = $dn -6;
goto report;
		}
// THU
if ($fd == 4) 	{
$dn = $dn -5;
goto report;
		}
// WED
if ($fd == 3) 	{
$dn = $dn -4;
goto report;
		}
// TUE
if ($fd == 2) 	{
$dn = $dn -3;
goto report;
		}
// MON
if ($fd == 1) 	{
$dn = $dn -2;
goto report;
		}
// SUN
if ($fd == 0) 	{
$dn = $dn -1;
goto report;
		}
End Replaced code */
// report:
?>

Now, I would still like to see a glossary of terms that defines a T_STRING, and there are some others I recall begin with capital T underscore.

I remember using # comment for Python have never tried that for PHP.
BTTT,
You have mixed HTML and PHP to a point f confusing me, cant help with that. If you need to print something like for use HEREDOC syntax. And goto? Can't beilieve it!

here is clean way of adding html in PHP

$form = <<<EOT
<form action={$_SERVER["PHP_SELF"]} method="post" enctype="multipart/form-data">
    <label for="file">Select File...</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
</form>

EOT;
echo $form;

Thank you for the heredoc idea. Like I said, the code was a whole lot less convoluted with switching out of PHP to print a paragraph, but now I have Googled heredoc and seen another description of what you said, and I will see if I can't make an even cleaner-looking code using heredoc syntax.

I was looking for a way to edit my post above, but I didn't see it. I have an errant ":" just right of a code example's HTML comment, where I was clarifying my use of exiting and entering PHP to display HTML.

Every clue I get is a help as I am fairly new to PHP programming.

evstevemd, Thanks again for the heredoc pointer.

Here below is some of my former code where I jumped out of PHP to print some HTML and jumped back in to resume parsing; I used heredoc syntax from top to bottom.

Couple of things to watch for with this heredoc syntax: DO NOT leave any whitespace after the opening TOC and similarly, place the ending TOC on the left margin, no blank space in front of it.

Oh. I had some PHP stuff left over in my HTML code that I had missed when I was rewriting the code to exit the PHP for HTML output, such as a \n and a couple quotes that weren't needed anymore. Discovered these as I rewrote with heredoc.

if ( (is_null($day)) and ($div = 0) ) {echo <<<EOT
<p class ="hilite">You did not enter a day of the week (3-letter abbreviation, surrounded with single quotes, as in 'sun') as first argument when calling function EOT; echo ' meetingDate().</p>
EOT;
 $x = 1; 
	}
if ( (is_null($week)) and ($div = 0) ) { echo  <<<EOT
<p class = "hilite">You have not entered which instance of the specified day in the month (1 to 5) for the second argument when calling function meetingDate().</p>
EOT;
 $x = 1; 
	}

if ( (is_null($m)) and ($div = 0) ) { echo  <<<EOT
<p class = "hilite">You have not entered a month (1 to 12) for the third argument when calling function meetingDate().</p>
EOT;
 $x = 1; }

edit: And I've found the edit button, over on the left side!
What I wanted to add was, I encountered a T_SL error, a rather cryptic message, when I wrote some test material that had a space between the opening EOT and the start of text on the same line. I did not test to see whether it is absolutely necessary to drop to the next line down, or if I would have had success with

echo <<<EOT<p>Paragraph</p>
EOT;

I had this with the space in front of the <p> tag:

echo <<<EOT <p>Paragraph</p>
EOT;

evstevemd, Thanks again for the heredoc pointer.

Enjoy and welcome to Daniweb!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.