Parse error: syntax error, unexpected T_SL in

Here’s the line of code that has an error:

$ahref = <<<CONTENT'<a href='dealer_details.php?id=__customer_no__'>__company_name__</a>'CONTENT;

I’m not a programmer so I have no idea what the error is with this code. I’d imagine it’s a space that needs to be removed or added?

Thanks, Bryan

The end of a HEREDOC statement must be on a line of its own


$ahref = <<<CONTENT'<a href='dealer_details.php?id=__customer_no__'>__company_name__</a>'
CONTENT;

Also, there are no spaces and/or no tabs allowed on the line before “CONTENT;”, it needs to be at the start of the line.

Still not working, here is two parts to show you how I’m stacking it:

$dbTable = new DBTable();
$ahref = <<<CONTENT'<a href=:dealer_details.php?id=__customer_no__">__company_name__</a>'
CONTENT;
$dbTable->add_col("Dealer Name", 1, "$ahref");
$ahref = <<<CONTENT'<a href="dealer_details.php?id=__customer_no__">__city__</a>'
CONTENT;

Thanks, Bryan

And if you do it without the heredoc, like so:

$dbTable = new DBTable();
$ahref = '<a href="dealer_details.php?id=' + __customer_no__ + '">' + __company_name__ + '</a>';
$dbTable->add_col("Dealer Name", 1, "$ahref");
$ahref = '<a href="dealer_details.php?id=' + __customer_no__ + '">' + __city__ + '</a>';

Heredocs for such short strings is not proper use of heredoc anyway (IMHO).

Thank you very much, that solved it.

Yeah, I’m a big believer in clean valid code too, when it comes to CSS / XHTML I’m all over it, but with PHP being so foreign to me there’s no way to know what’s good, clean and valid syntax.

I learn by doing, practicing, experience. But, that doesn’t quite apply to PHP for me anyways because of it’s complexity, you really need to know what function is what or else you’ll just be staring at error messages and won’t really get to play around all that much.

I’m too hands on to pick up a book on it, so I’ll just have to stick to the front-end and keep working with/hiring back-end programmers, they need to eat too ;).

To make life easier you could use a template engine like Smarty.

That way you don’t have to use PHP, but a simple syntax like


<html>
<head>
<title>User Info</title>
</head>
<body>

User Information:<p>

Name: {$name|capitalize}<br>
Addr: {$address|escape}<br>
Date: {$smarty.now|date_format:"%Y-%m-%d"}<br>

</body>
</html>

Take a look at their crash course :slight_smile:

Yes, that is definitely more my style, definitely worth a look. I like clean, easy to understand “English” type code like that.

Thanks again, Bryan