Flushdrew Flushdrew - 6 months ago 17
PHP Question

Infinite loop. Why?

i wanna test if my variable is empty or not to display some differents things.
When i don't use the else...if everything work but when i use this code :

<?php
$Amazon = get_post_meta($post->ID, "Lien Amazon", true);
?>
<?php
if( $Amazon != NULL ){
echo '<li><span class="post-meta-key"><a href=". $Amazon . ">Acheter sur Amazon</a></li>' ;}
else {
echo '<li><span class="post-meta-key"><a href="https://www.amazon.fr/bd/b?ie=UTF8&node=301133">Acheter sur Amazon</a></li>' ;}
?>


What is the problem ? Thank you

Answer

Here is an output error. You haven't closed and reopened the string on trying to concat a variable.

echo '<li><span class="post-meta-key"><a href=". $Amazon . ">Acheter sur Amazon</a></li>' ;

Do instead:

echo '<li><span class="post-meta-key"><a href="'. $Amazon . '">Acheter sur Amazon</a></li>' ;
Comments