What is wrong with this echo?

Hi all.

I’m trying to echo a variable followed by a link and Dreamweaver’s code hinter keeps flagging it up as an error.

The variable is $truncated which takes a string and shortens it to 130 characters or less (without cutting in the middle of a word). This is the $truncated variable.

$truncated = substr($longstring,0,strpos($longstring,' ',130));

And now I want to create another variable that takes the shortened text and adds a “Read More” link afterwards…

I’m doing it like this:

$msg = echo($truncated "<a href='http://ivegotkids.com/aries'>Read More</a>");

Dreamweaver keeps on telling me that last line is incorrect.

I have also tried it with a comma after $truncated…

$msg = echo($truncated, "<a href='http://ivegotkids.com/aries'>Read More</a>");

I have also tried it by putting the link in a separate variable called $url and echoing both like this:

$msg = echo($truncated, $url);

I have also tried all three of the above without the brackets.

What should it be?

$msg = echo $truncated . “<a href=‘http://ivegotkids.com/aries’>Read More</a>”;

You forgot the concatenation operator between the variable and the string, also you don’t need () around an echo

either

$msg =

or

echo

but not both in the one statement unless you swap them around the other way

echo $msg =

$msg = " $truncated <a href='http://ivegotkids.com/aries'>Read More</a>";

The variable can go inside the " as any variable inside a set of " is parsed.

That doesn’t change the fact that you cannot have $msg = echo which is what the code reads that isn’t working.