how can I incorporate the code in php in "My Code" part?

```
$out.= '<li class="portfolio_item overlayed_animated_highlight portfolio_item_4' . $slugs . '">
            <div class="overlayed">
                ' . get_the_post_thumbnail() . '
                <div class="overlay">
                    <p>
                        <a href="'.get_permalink().'"><i class="icon-share"></i></a>
                        <a href="'.$thumbnail_src.'" class="fancybox" data-fancybox-group="portfolio"><i class="icon-search"></i></a>
                    </p>
                </div>
            </div>
            /** my code **/
            <h4><a href="' . get_permalink() . '">' . get_the_title() . '</a></h4>
            <span>' . get_the_date() . ' // ' . $in_category . '</span>
        </li>';

```

/\*\* my code\*\*/

```
<?php if( get_field('field_name') ): ?>
<div><?php the_field('field_name'); ?></p></div>
<?php endif; ?>

```