• I am not good with PHP but I am learning…. quick question. Why can’t I echo PHP within a PHP tag?

    Here is what I am trying to do… but it’s not working:

    <?php
    function my_super_admin_widget() {
    global $blog_id;
    if( $blog_id == '42' ) {
    echo '<?php if (function_exists('easing_slider')){ easing_slider(); }; ?>'; }
    }
    ?>

    Thanks for your help!

Viewing 15 replies - 1 through 15 (of 17 total)
  • Anonymous User

    (@anonymized-3085)

    try this instead:

    if( $blog_id == '42'  &&  function_exists('easing_slider') ) {
    echo easing_slider();
    }

    Thread Starter bwinn

    (@bwinn)

    that worked like a charm!!! Thanks so much Rich! Mucho mucho appreciated!!

    Thread Starter bwinn

    (@bwinn)

    I am getting this showing up in the admin panel however….

    header information – headers already sent by (output started at /home/mysite/public_html/wp-content/mu-plugins/sponsor_ad_widget.php:13) in /home/mysite/public_html/wp-includes/functions.php on line 830

    Warning: Cannot modify header information – headers already sent by (output started at /home/mysite/public_html/wp-content/mu-plugins/sponsor_ad_widget.php:13) in /home/mysite/public_html/wp-includes/functions.php on line 831

    Anonymous User

    (@anonymized-3085)

    then you probably have a ‘space’ in the functions file before an opening <?php

    anr/or an error in your php code.

    and no don’t post it here use http://wordpress.pastebin.ca

    Thread Starter bwinn

    (@bwinn)

    Thread Starter bwinn

    (@bwinn)

    See what my error would be? I am not catching it…

    Anonymous User

    (@anonymized-3085)

    the error is probably in this file:
    wp-content/mu-plugins/sponsor_ad_widget.php

    Thread Starter bwinn

    (@bwinn)

    So this is the code I have in that file now, based on what you recommended:

    <?php
    function my_super_admin_widget() {
    global $blog_id;
    if( $blog_id == '42'  &&  function_exists('easing_slider') ) {
    echo easing_slider(); }
    if( $blog_id == '999' ) {
    echo 'stuff goes here too'; }
    }
    ?>
    Anonymous User

    (@anonymized-3085)

    can’t see anything wrong there, are you sure there are no extras lines before, or after the php opening/closing tags?

    Thread Starter bwinn

    (@bwinn)

    Hmmm…. not sure? You saw both the files right?

    What opening/closing tags are you referring to?

    Anonymous User

    (@anonymized-3085)

    <?php ... ?>

    and there is nothing else in there?

    Thread Starter bwinn

    (@bwinn)

    Nothing more than what you see in the 2 files… [:/)

    You may not be able to see trailing spaces. Try following the instructions in this Codex page on those 2 files.

    Thread Starter bwinn

    (@bwinn)

    What the… I haven’t even made any changes and it’s bringing up this error now…

    “Warning: Cannot modify header information – headers already sent by (output started at /home/mysite/public_html/wp-content/mu-plugins/sponsor_ad_widget.php:12) in /home/mysite/public_html/wp-includes/pluggable.php on line 890”

    I looked at pluggable.php and it doesn’t even have 890 lines of code. I am stumped!

    The issue is in sponsor_ad_widget.php

Viewing 15 replies - 1 through 15 (of 17 total)

The topic ‘echo PHP within PHP?’ is closed to new replies.