简体   繁体   English

我正在尝试使用$ _GET更改CSS属性以获得错误的结果

[英]I'm am trying to change a css property using $_GET getting wrong result

First of all this is a wordpress page so [insert_php] is a replacement for <?php . 首先,这是一个wordpress页面,因此[insert_php]替代了<?php

The url of the page is as follows http://********.com/?page_id=98#highlights?sel=q1s 该页面的网址如下http://********.com/?page_id=98#highlights?sel=q1s

the code on the page is as follows 页面上的代码如下

<div id="Question1" style="background-color:[insert_php] if ($_GET['sel'] == "q1s") { echo "black"; } else { echo "white"; }[/insert_php];">

this is my current code and it still showing no results, I checked the actual value I'm getting for background-color and for some reason am getting the result "white". 这是我当前的代码,它仍然没有显示任何结果,我检查了我为background-color获得的实际值,并且由于某种原因得到了结果“ white”。

This is because the second parameter sel passed in the URL should be directly appended to the first argument declared with the ampersand ( & ) identifier. 这是因为URL中传递的第二个参数sel应该直接附加到用&标识符声明的第一个参数后面。

The use of the fragment identifier ( # ) in the middle of your arguments is misleading as he can also be used to declare arguments to the URL. 在参数中间使用片段标识符( # )具有误导性,因为他也可以用于声明URL的参数。 If the hash mark is meant to identify an anchor, it is better to place it at the end for avoiding errors and better readability : 如果哈希标记用于标识锚点,则最好将其放在末尾,以避免错误和更好的可读性:

http://you-url.com/?page_id=98&sel=q1s#highlights

Try something 试试看

<div id="Question1" style="background-color:[insert_php] if ($_GET['sel'] == "q1s") { echo "black"; } else { echo "white"; }[/insert_php];">
[insert_php] echo $_GET['sel'];[/insert_php]
</div>

and see what is in the $_GET 并查看$ _GET中的内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试使用$ _GET更改css属性但是没有得到结果 - I'm am trying to change a css property using $_GET but am not getting results 我在尝试获取非对象的属性时遇到错误 - i am getting error as trying to get property of non object 我正在尝试为我的网站创建一个更改密码页面。 我究竟做错了什么? - I'm trying to make a change password page for my website. What am I doing wrong? 当我尝试使用带有PHP的date函数显示时间时,为什么会得到“ 4:00”? - why am I getting '4:00' when I'm trying to display time using the date function with php? 为什么会出现下一个错误:试图获取非对象的属性? laravel - Why am I getting next error: Trying to get property of non-object? laravel 为什么我要尝试获取AngularJs中非对象错误的属性? - Why i am getting trying to get property of non-object error in AngularJs? 为什么我要在Laravel Eloquent中尝试获取非对象的属性 - Why I am getting Trying to get property of non-object in Laravel Eloquent 为什么我在 PHP 中收到“试图获取非对象的属性”错误? - Why am I getting a "trying to get a property of a non-object" error in PHP? 我从控制器收到“尝试获取非对象的属性”错误 - I am getting a “Trying to get property of non-object” error from my controller 我收到此错误“试图获取非对象的属性”,但它在另一台计算机上工作正常吗? - I am getting this error "Trying to get property of non-object" , but its working fine in another Computer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM