Forum Moderators: coopster

Message Too Old, No Replies

pass variables from class to separate php file which is parsed as css

pass variables from class to separate php file

         

sonill

6:24 am on Apr 26, 2010 (gmt 0)

10+ Year Member



hey i have a page where i have a class and it contains some variables for css values.
the problem is how do i pass the values of that class to the separate php file which is parsed as css file.

my page structure is like this

<?php include('someclass.php');?>
<html>
<head>
<title>title</title>
<link href="style.php" rel="stylesheet" type="text/css">
</head>
<body>
<?php $data=new data;
$data->activate();
?>
</body>
</html>

this page works fine but i need to send the variables of the class to the php(css) file, how do i do it?

Tommybs

8:43 am on Apr 26, 2010 (gmt 0)

10+ Year Member



Hi,

You'd need to instantiate your class above the style.php file. Then within your style.php file you should be able to access the particular object and any of the properties associated with it.

sonill

8:59 am on Apr 26, 2010 (gmt 0)

10+ Year Member



i had done so, I had created the object, but when i echo the variable(just to make sure it is working) it does not echo anything nor does output the error.

Tommybs

6:50 am on Apr 27, 2010 (gmt 0)

10+ Year Member



Hi,

Sorry that won't work as you're linking to a stylesheet even though it's a php page. If you change the

<link href="style.php" rel="stylesheet" type="text/css">

to

<?php include_once("style.php");?>


then it should work. Though just remember to amend style.php to include the style tag.

<style type="text/css">

Of course this does mean your styles will be inline. Otherwise I think you would need to include the class file on style.php and instantiate a class member on the style page. Possibly using info from the master page to send a querystring if you need to

sonill

7:44 am on Apr 27, 2010 (gmt 0)

10+ Year Member



i think 1st option will work, i has tried including the class and creating object( as i mentioned earlier) and it didn't work.