How do I store a block of html (with embeded PHP) in a PHP variable?

Arthuribbs

New Member
I am new to wordpress themes and PHP. (I don't believe this is specific to WP) I would like to know the best way to store a block of HTML (with embeded PHP code) in a PHP variable. \[code\]<?phpfunction rfttc_insert_nav_menu ($position){$poswanted = 'above';$nav_code = '<nav id="site-navigation" class="main-navigation" role="navigation"> <h3 class="menu-toggle"><?php _e( \'Menu\', \'twentytwelve\' ); ?></h3> <a class="assistive-text" href="http://stackoverflow.com/questions/14534147/#content" title="<?php esc_attr_e( \'Skip to content\', \'twentytwelve\' ); ?>"><?php _e( \'Skip to content\', \'twentytwelve\' ); ?></a> <?php wp_nav_menu( array( \'theme_location\' => \'primary\', \'menu_class\' => \'nav-menu\' ) ); ?> </nav><!-- #site-navigation -->'if($position == $poswanted) return $nav_code;}?>\[/code\]Reading through many questions here leads me to believe that nowdoc and heredoc are not good choices. I have tried single quotes and escaping the single quotes inside. Same with double quotes. Both attempts resulted in error messages. Any help here would be appreciated.
 
Back
Top