In my css
div.image {
width:<?php echo get_image_size( $size[1] ); ?>px;
}
The size is stored in an array so i called $size[1] to here...
I am beginner in php...
any one pls help?
Putting PHP code in a CSS file will not work. You will have to create a PHP file first, and let that output CSS code. And also set the correct content type headers.
Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the PHP. Step 2: Now, we have to place the cursor in any tag of the <body> tag where we want to add the code of PHP. And, then we have to type the start and end tag of PHP.
PHP is designed to interact with HTML and PHP scripts can be included in an HTML page without a problem.
There is no way to style within PHP. You can either put your CSS in a separate file and link to it with a <link> tag or you could put it in <style> tags in the head of the document and then using class="mycssclass" , or you put it as a style attribute within the HTML.
Better solution is to set a header for the css / php file in my example cssfile.php:
<?php header("Content-type: text/css"); ?>
Then you can use the php file as style.
<link rel="stylesheet" type="text/css" href="cssfile.php?param=1" />
Then you should get the output on your site. But with that solution you should be very careful if you have a lot of traffic. On every site call your PHP interpreter is used to deliver that file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With