PHP& CSS输出问题 [英] PHP & CSS Output Problem

查看:289
本文介绍了PHP& CSS输出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设置,以便我可以操纵$ backgroundcolor =#00FFFF;
在另一个.php文件?

How do I set this up so that I can manipulate $backgroundcolor = "#00FFFF"; on another .php file?

最初我只是想要能够更改$ backgroundcolor =#00FFFF的值;
从另一个表单,根据用户输入hrefed到这个表单(style.php)。

Initially I just want to be able to change the value of the $backgroundcolor ="#00FFFF"; From another form that is hrefed to this form (style.php) based on user input.

我在这个表单上试过了, $ backgroundcolor不同的值:
$ backgroundcolor =;

I Tried this on this form so that I could hopefully give $backgroundcolor different values: $backgroundcolor = " ";

然后我使用另一个.php形式hrefed到这个style.php脚本调用$ backgroundcolor =一些不同的十六进制颜色,没有结果;

Then I used another .php form that is hrefed to this style.php script to call $backgroundcolor ="some different hex color with no results";

事实上,我看到的只是值#0033FF的输出,但我不想输出,我想要新值#0033FF
是背景颜色?

In fact all I saw was the output of the value #0033FF, but I don't want the output, I want the new value #0033FF to be the background color?

<?php header("Content-type: text/css"); 
$backgroundcolor = "#00FFFF ";
$textcolor = " #0033FF";
?>
body {
 background:<?php  echo $backgroundcolor?>;
 color:<?php echo $textcolor?>;
}


推荐答案

这个想法是让所有的css和php代码设置如下:

The idea is to get all the css and php code setup like this:

$ backgroundcolor = $ _REQUEST [backgroundcolor];

$backgroundcolor = $_REQUEST["backgroundcolor"];

背景颜色:$ backgroundcolor;

background-color:$backgroundcolor;

在传统CSS中给你的背景颜色,我们将使用一个变量,在这种情况下$ backgroundcolor;

Where background-color: will give you the color of the background in traditional CSS, we will use this with a variable, in this case $backgroundcolor;

在html端,我们将有一个形式这:

On the html side we will have a form like this:

<select name = "backgroundcolor">
<option value = "#000000">Black</option>
<!-- And all we have to do is add multiple options for the different color values      
and the php script will do the rest after the user has selected 
the color he or she wants, done-->


#heredoc
$theStyle = <<<HERE
"border-width:$borderSize$sizeType;
background-color:$backgroundcolor;
color:$fontcolor;
border-style:$borderStyle;
border-color:green"
HERE;

这篇关于PHP&amp; CSS输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆