Here is the code:
$vote_up = '<a href="<?php amc_comment_vote("up") ?>">Vote Up</a>';
I am simply trying to have my PHP function insert a link that has a line of PHP as the href
. But it does not work right. How can I do this?
Quick update: I got some good answers, however I'd like for the function to fire when clicked (hence the need for the <?php
tags).
You're trying to use PHP tags inside the string context. They have no meaning and hence won't produce the output you need.
Simply use string concatenation:
$vote_up = '<a href="' . amc_comment_vote("up") . '">Vote Up</a>';
Or use sprintf()
(bit more cleaner):
$vote_up = sprintf('<a href="%s">Vote Up</a>', amc_comment_vote("up"));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments