0

I am currently on Wordpress 4.1 and want to make variable css values, which get generated via PHP. First I created a file named styling.php that I imported in the default Wordpress stylesheet style.css using @import url(../genesis/style.css);

Then I added a simple code into the styling.php, where the content is as follows:

   <?php 
    header("Content-type: text/css; charset: UTF-8");
    $TopColor = #FFE211;
    ?>

    .site-header {
    background-color: <?php echo $TopColor; ?>;
    }

But this give me the debugging error "Parse error: syntax error, unexpected '?>' in line 4" and I do not know how to fix this

4
  • 2
    You need to quote the value #FFE211 Commented Jan 5, 2015 at 19:46
  • 2
    put the color in quotes '#FFE211' Commented Jan 5, 2015 at 19:46
  • 1
    wait, what? Yeah, what everyone else said, you need to quote your $TopColor value. Commented Jan 5, 2015 at 19:47
  • I guess those are your css code.So you need them inside style tag otherwise it will not work and will output them as plain text at your browser Commented Jan 5, 2015 at 19:50

1 Answer 1

4

You forgot to quote your color:

$TopColor = #FFE211;
            ^------^

Since it starts with #, it's treated as a comment, and the rest of the line is ignored. That means you've effectively got

$TopColor = ?>

and are missing the assignment value.

Try

$TopColor = '#FFE211';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.