问题描述:

When I use php to create a button's value and the value is a two word string, only the first word is displayed on the button.

Both of the below buttons should show "Compare All" but instead the first one only displays "Compare" on the button.

(Note: I do need to use php for this conditional button value. this is just a simplified version of more complex code for clarity.)

<?php

$ButtonDisp = 'Compare All'; //The two words that should appear on first button

?>

<input name="comp_homes" type="submit" value=<?php echo $ButtonDisp ; ?> // only the first word appear>

<br />

<input name="comp_homes" type="submit" value="Compare All"> <!--This works/shows two words-->

网友答案:

You're missing quotation marks around the value:

<input name="comp_homes" type="submit" value="<?php echo $ButtonDisp ; ?>">
网友答案:

Because you didn't quote it:

<input name="comp_homes" type="submit" value="<?php echo $ButtonDisp ; ?>" />
相关阅读:
Top