Title: Help with PHP string concatenation
Last modified: August 19, 2016

---

# Help with PHP string concatenation

 *  Resolved [adalberto.solito](https://wordpress.org/support/users/adalbertosolito/)
 * (@adalbertosolito)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/help-with-very-little-php-code/)
 * Hi. I don’t know PHP very well and I want to optimize this PHP snippet. In this
   code I’m creating the $image variable, which stores the data of the custom field“
   Immagine Grande”.
    What I want to optimize is the href attribute of the a element,
   which at the end repeats “get_post_meta…” . I would like to use string concatenation
   but I don’t know how to use it in PHP. Thank you for your help.
 *     ```
       <?php $image = get_post_meta($post->ID, 'Immagine Grande', true); if($image != '') : ?>
   
       <a href="<?php bloginfo('template_directory'); ?>/images/products/<?php echo get_post_meta($post->ID, 'Immagine Grande', true); ?>" rel="lightbox">
       <img src="<?php bloginfo('template_directory'); ?>/images/icons/zoom_24.png" alt="<?php _e("Immagine del Prodotto", "mytextdomain"); ?>" />
       </a>
   
       <?php endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [adalberto.solito](https://wordpress.org/support/users/adalbertosolito/)
 * (@adalbertosolito)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/help-with-very-little-php-code/#post-1208924)
 * No more problems. I fixed it by myself after half an hour of experimenting!
 * 🙂

Viewing 1 replies (of 1 total)

The topic ‘Help with PHP string concatenation’ is closed to new replies.

## Tags

 * [concatenation](https://wordpress.org/support/topic-tag/concatenation/)
 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [link](https://wordpress.org/support/topic-tag/link/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [snippet](https://wordpress.org/support/topic-tag/snippet/)
 * [string](https://wordpress.org/support/topic-tag/string/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 1 reply
 * 1 participant
 * Last reply from: [adalberto.solito](https://wordpress.org/support/users/adalbertosolito/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/help-with-very-little-php-code/#post-1208924)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
