WordPress.org

Ready to get started?Download WordPress

Forums

PHP Help Please.. (3 posts)

  1. rellison
    Member
    Posted 3 years ago #

    I have a section of PHP code that looks like this

    <?php $header = $suf_header_fg_image_type == 'image' ? "<img src='$suf_header_fg_image' alt='".get_bloginfo('name')."'/>" : get_bloginfo('name');
    	if ($suf_sub_header_vertical_alignment == "above") {	?>
       		<div class="description"><?php echo bloginfo('description');?></div>
       		<div class="blogtitle"><a href="<?php echo get_option('home');?>"><?php echo $header;?></a></div>

    I need to add an image into the header that is part of a javascript that is loaded previous to this. I want to do something like this..

    <?php $header = "<img id='Rotating1' border='0' '/>";
     $header = $header . $suf_header_fg_image_type == 'image' ? "<img src='$suf_header_fg_image' alt='".get_bloginfo('name')."'/>" : get_bloginfo('name');

    But I keep getting a syntax error in the newly added line. I have sat here for 3 hours now trying to figure this out. Could someone show me the correct format I am supposed to use to do this??

    Thanks

    Rick

  2. wprelief
    Member
    Posted 3 years ago #

    Try this:

    <?php $header = "<img id='Rotating1' border='0' />";
     $header = $header . ($suf_header_fg_image_type == 'image' ? "<img src='$suf_header_fg_image' alt='".get_bloginfo('name')."'/>" : get_bloginfo('name'));
  3. Mark / t31os
    Moderator
    Posted 3 years ago #

    Or.

    <?php
    $header = '<img id="Rotating1" border="0" />';
    // Concatenate
    $header .=
    // Ternary conditional check
    ( 'image' == $suf_header_fg_image_type )
    // Assignment if condition true
    ? '<img src="' . $suf_header_fg_image . '" alt="' . get_bloginfo('name') . '" />'
    // Else assignment
    : get_bloginfo('name');

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags