Title: php code in a variable?
Last modified: August 18, 2016

---

# php code in a variable?

 *  [mdlewis11](https://wordpress.org/support/users/mdlewis11/)
 * (@mdlewis11)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/php-code-in-a-variable/)
 * I would like $rr to contain the entire link code below. The code runs fine standing
   on it’s own. But when trying to add it to a variable, I get a “Parse error: parse
   error, unexpected ‘<‘ “.
 * ‘<?php $rr=<p class=”centerP”>” rel=”bookmark” title=”Permanent Link: <?php the_title();?
   >”>**[Read More]**** ?>’**
 * I’m really php ignorant and w3Schools.com isn’t much help.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [mdlewis11](https://wordpress.org/support/users/mdlewis11/)
 * (@mdlewis11)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/php-code-in-a-variable/#post-198215)
 * A second attempt at getting enough backtick in place…
 * <?php $rr=<p class=”centerP”>” rel=”bookmark” title=”Permanent Link: <?php the_title();?
   >”>’**‘[Read More]’**” ?>
 *  [skippy](https://wordpress.org/support/users/skippy/)
 * (@skippy)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/php-code-in-a-variable/#post-198216)
 * Try this:
    `<?php $rr = '<p class="centerP"><a href="foo.com" rel="bookmark" 
   title="'. the_title() . '">[Read More]'; ?>`
 *  [darkcanuck](https://wordpress.org/support/users/darkcanuck/)
 * (@darkcanuck)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/php-code-in-a-variable/#post-198244)
 * Except that `the_title()` echoes its output by default… To capture the value 
   of the title in the variable $rr try:
 * <?php $rr = '<p class="centerP"><a href="foo.com" rel="bookmark" title="'. the_title('','',
   false) . '">[Read More],</a>'; ?>

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘php code in a variable?’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [darkcanuck](https://wordpress.org/support/users/darkcanuck/)
 * Last activity: [20 years, 11 months ago](https://wordpress.org/support/topic/php-code-in-a-variable/#post-198244)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
