Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:40:33+00:00 2026-05-31T11:40:33+00:00

I’m using this php code code to write out my css with populated variables.

  • 0

I’m using this php code code to write out my css with populated variables.

I want to move the default array out of this code and lift it to a settings.php file for my site but when I do I get this error message:

<b>Warning</b>:  extract() [<a href='function.extract'>function.extract</a>]: First argument should be an array in <b>/home/drawapl1/public_html/ezamazon/demo/css/stylesheet.php</b> on line <b>19</b>

My code is as follows:

in index.php:

<?php
include("settings.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="css/stylesheet.php" rel="stylesheet" type="text/css" media="screen" />

in stylesheet.php:

/* get the stylesheet */
$stylesheet = @is_file($_GET['stylesheet']) && strtolower(substr(strrchr($file_name,'.'),1)) == 'css' ? $_GET['stylesheet'] : 'global.css';

/* set the header information */
//will be output as css
header('Content-type: text/css');
//set an expiration date
$days_to_cache = 10;
header('Expires: '.gmdate('D, d M Y H:i:s',time() + (60 * 60 * 24 * $days_to_cache)).' GMT');

//red css variable information
//$red = array(
  //'body_font_size' => '10px',
  //'body_text_color' => '#f00'
//);

/* extract the propery array's information */
extract($_GET['theme'] && ${$_GET['theme']} ? ${$_GET['theme']} : $defaultCSS);

/* load in the stylesheet */
$content = preg_replace('/\$([\w]+)/e','$0',@file_get_contents($stylesheet));

/* spit it out */
echo $content;

in settings.php:

$defaultCSS = array(
'body_background_colour' => 'white',
'body_text_colour' => 'black',
'body_font_size' => '1em',
'body_font_family' => 'Arial, Helvetica, sans-serif',
'h1_text_colour' => 'black',
'h2_text_colour' => 'black',
'h3_text_colour' => '#E47911',
'a_text_colour' => '#004B91',
'a_hover_text_colour' => '#2A70FC',
'news_block_background_colour' => '#EAF3FE',
'left_nav_border_colour' => '#C9E1F4',
'left_nav_h2_background_colour' => '#EAF3FE',
'button_text_colour' => '#FFFFFF',
'button_background_colour' => '#414953',
'button_hover_background_colour' => '#999999',
'price_colour' => '#990000',
'price_heading_colour' => '#666666',
'nav_links_colour' => 'black',
'nav_hover_links_colour' => '#E47911',
'hr_divider_colour' => '#DDDDDD',
'pagination_highlight_colour' => '#645538'
);

Any idea what the issue is?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:40:35+00:00Added an answer on May 31, 2026 at 11:40 am

    Make sure you are using include() to include settings.php before everything.

    The most likely reason this isn’t working is that the file doesn’t know see a $default variable, and creates a new null variable for the parameter.

    Try this:

    //settings.php
    
      /* set the dynamic information */
      //default css variable information
      $default = array(
        'body_font_size' => '16px',
        'body_text_color' => '#00f'
      );
    
    //main_php_file.php
    
      include('settings.php'); // This is the important part
    
      /* extract the propery array's information */
      extract($_GET['theme'] && ${$_GET['theme']} ? ${$_GET['theme']} : $default);
    

    Also try print_r($default) after include('settings.php'); to make sure that $default is set properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.