php - If variable is link, echo link -


i having issues getting function echo, $lightbox_link1 = get_custom_field('lightbox_link1'). i'm new php.

below defining function:

// check lightbox link, if exists, use value.  // if doesn't, use featured image url above. if(get_custom_field('lightbox_link1')) {                                 $lightbox_link1 = get_custom_field('lightbox_link1'); } else {                                 $lightbox_link1 = $image_full[0]; } 

echo function:

<?php if ($lightbox_link1 = get_custom_field('lightbox_link1')) {      echo '<a href="<?php echo $lightbox_link1; ?>" data-rel="prettyphoto[<?php echo $post_slug; ?>]"></a>'; } ?> 

<?php if ($lightbox_link1 = get_custom_field('lightbox_link1')) { 

should be

<?php if ($lightbox_link1 == get_custom_field('lightbox_link1')) { 

= used assignment

== used comparison

=== used typesafe comparison

also can't declare <?php ... ?> inside <?php ... ?>

to <?php ... <?php ... ?> ... ?>

take @ did here:

 <?php if ($lightbox_link1 = get_custom_field('lightbox_link1')) {     echo '<a href="<?php 

instead, using doublequotes in echo statement allow php variables inside parsed, do

echo "<a href='{$lightbox_link1}' data-rel='prettyphoto[{$post_slug}]'></a>"; 

to get

<?php if ($lightbox_link1 == get_custom_field('lightbox_link1')) {      echo "<a href='{$lightbox_link1}' data-rel='prettyphoto[{$post_slug}]'></a>"; } ?> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -