I’m kinda new to PHP and I’m trying to add a tag within a PHP variable.
This is what I have, and it’s not working.
$linkText .= "<span>" . ( 'Reply', $this->_slug ) . "</span>";
Can anyone please point me in the right direction?
Thanks 🙂
UPDATE:
This is the complete working code:
$linkText = __( 'Reply', $this->_slug );
$linkAttrs['href'] = "http://twitter.com/intent/tweet?in_reply_to={$tweet->id_str}";
$linkAttrs['class'] = 'in-reply-to';
$linkAttrs['title'] = $linkText;
$widgetContent .= $this->_buildLink( $linkText, $linkAttrs );
What I’m trying to do here is to add a tag around $linkText so that I get a result like
<a href="#"><span>Title</span></a>
There’s no need for brackets, you can basically concatenate (join) strings and variables using
.. I have merged the ‘Reply’ into the span tag as they are both strings, only the PHP variable$this->_slugand and the strings need separating with.Here is the manual page for strings in PHP.
Based on your update, and checking out the twitter plugin source code, here is the code I think you need:
I’ve also passed a
trueparameter to thebuildLink()which prevents the<span>tag from being escaped.