Simple PHP question - merging two codes

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

peterspliid
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Nov 06, 2012 12:58 pm

Simple PHP question - merging two codes

Postby peterspliid » Tue Nov 06, 2012 1:01 pm

Hi, i'm not very experienced with php yet, and i'm trying to merge two php codes into each other, but I'm running out of luck.

I have the following code:

Code: Select all

<?php if ( $format == 'gallery' ) echo '
<div id=spotlightg>
Contributer Spotlight
</div>
<div id=gcontent>
Info
</div>
<br /><br /><br />'; else echo ''; ?>


And where is says info (between two divs), I want to add this code

Code: Select all

<header class="entry-header">
      <?php do_action( 'gpp_before_title' ); ?>
      <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'gpp' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
      <?php do_action( 'gpp_after_title' ); ?>
   </header>


This code contains html and php, so it can't all be in an echo, due to the php part. I just need this to be between those two divs. How do i manage to do this?

Thanks!

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Simple PHP question - merging two codes

Postby egami » Tue Nov 06, 2012 1:48 pm

where's the include for the functions you have created? Seems to me, without that, you're S.O.L.

us2rn4m2
New php-forum User
New php-forum User
Posts: 17
Joined: Thu Aug 09, 2012 1:28 pm

Re: Simple PHP question - merging two codes

Postby us2rn4m2 » Tue Nov 06, 2012 1:49 pm

Code: Select all

<?php
if ($format == 'gallery') : ?>
   <div id="spotlightg">
      Contributer Spotlight
   </div>
   <div id="gcontent">
      <header class="entry-header">
         <?php do_action( 'gpp_before_title' ); ?>
         <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'gpp' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
         <?php do_action( 'gpp_after_title' ); ?>
      </header>
   </div>
   <br /><br /><br />
<?php else : echo ''; endif; ?>
Last edited by us2rn4m2 on Sun Nov 11, 2012 9:20 am, edited 4 times in total.

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Simple PHP question - merging two codes

Postby egami » Tue Nov 06, 2012 2:03 pm

Negative Houston...



The functions you have are not defined in your PHP, they are only 'called'.
without the definition of the function, you're not going to get it to work, ever.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron