WordPress.org

Support

Support » How-To and Troubleshooting » PHP Help Please..

PHP Help Please..

  • 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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'));

    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');

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Help Please..’ is closed to new replies.
Skip to toolbar