我设置了一个类,简化了这个:
class Labels {
static public $NAMELABEL = "Name";
}
Run Code Online (Sandbox Code Playgroud)
我成功地得到以下代码才能正常工作:
echo '<table border="1">';
echo '<tr>';
echo "<th>" . Labels::$NAMELABEL . "</th>";
echo '</tr>';
// the rest of the Table code not shown for brevity...
echo "</table>";
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我看到一个带有名为Name的列标题的表- 所以它工作正常.
但不是在heredoc中 - 当我运行以下内容时,我得到"注意:未定义的变量:NAMELABEL在C:\ xampp ........ blah blah":
echo <<<_END
<form action="index.php" method="post"><pre>
Labels::$NAMELABEL : <input type="text" name="author" />
<input type="submit" value="ADD RECORD" />
</pre></form>
_END;
Run Code Online (Sandbox Code Playgroud)
我已经尝试了各种引用,字符串连接运算符'.',没有任何作用.我想"我有静态类变量在HTML表中工作,为什么不是 heredoc."
我喜欢heredocs,他们有一个奇怪的名字和奇怪的问题.这是我渴望的那种令人心碎的乐趣,heredocs是正义的小doosh猴子.
我真的想在这里使用我的静态类变量 - 引用/字符串连接的某些组合是否允许我将它们嵌入到我的heredocs中?
好吧,我似乎无法heredoc
在我的foo.php
文件中的块内添加注释:
echo <<<_HEREDOC_FOO
// okay this comment was intended to explain the code below but it
// is showing up on the web page HTML sent to the browser
<form action="foo.php" method="post">
<input type="submit" value="DELETE RECORD" /></form>
_HEREDOC_FOO;
Run Code Online (Sandbox Code Playgroud)
该表单是否有效,确定(顺便提一下上面的表单代码是为了我的问题而高度截断).
但dang comment(okay this comment was..blah blah blah
)也出现在浏览器中.它在浏览器中显示如上所示:
// okay this comment was intended to explain the code below but it
// is showing up on the web page HTML sent to the browser …
Run Code Online (Sandbox Code Playgroud) 应该很容易吧?只需将包含div的外部填充设置为零,并将外部div内的两个并排div设置为余量:0但这对2个水平div之间的空间没有影响.我需要的是红色轮廓的左侧div来触摸绿色轮廓的右侧div.
尽管我努力使用填充和边距,但两个div之间的空间不会消失.
我已经看了很多关于SO的答案,但到目前为止还没有人把它分解为这个简单的例子 - 我的小提琴显示了这个问题,
http://jsfiddle.net/Shomer/tLZrm/7/
这是非常简单的代码:
<div style="border: 4px solid blue; white-space:nowrap; margin:0; padding:0; width:80%">
<div style="display:inline-block; width:45%; overflow:hidden; margin:0; border: 1px solid red"> Flimmy-flammy
</div>
<div style="display:inline-block; width:50%; overflow:hidden; margin:0px; border: 1px solid green"> Hambone-Sammy
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 最外面的容器div有两个内部div - 右侧内部div具有可以根据用户输入增长或缩小的文本(稍后,通过设置其高度:250px,现在在文本div中模拟大量文本).奇怪的是 - 随着右侧内部div的高度增加 - 左侧内部div'在外部div中向下".我在div周围放置了彩色轮廓 - 左内部div,带有'fall'问题的轮廓有蓝色轮廓."由于用户输入的文本而增长"是右边的内部div,带有紫色边框.
2个内部div的外部容器具有橙色轮廓.
我需要带有蓝色边框的左侧div为100%不受影响或不受输入文本量的影响.带有蓝色边框的div 必须保留在具有橙色边框的外部容器div的左上角.
为什么右侧绿色div中的盒子高度会向左推动div?
这是一个链接,可以看到发生了什么:
http://jsfiddle.net/Shomer/JSyYY/
这是代码:
<div style="display:inline-block; border: 4px solid orange;">
<div style="border: 2px solid blue; display:inline-block;">
<div style="display:inline-block; border: 1px solid red;">topleft
</div>
<div style="display:inline-block; border: 1px solid red;">topright
</div>
<div>lower div
</div>
</div>
<div style="display:inline-block; border: 3px solid purple;">
<div style="display:inline-block; height:250px; border: 1px solid red;"> "text"
</div>
<div style="display:inline-block; margin-top:0; border: 1px solid red;"> <b>button</b>
</div>
<div> </div>
</div>
/div>
Run Code Online (Sandbox Code Playgroud) 我对基本HTML DOM元素的研究说明了任何DOM元素的"样式"属性(来自http://www.w3schools.com/jsref/dom_obj_all.asp):
"style -- Sets or returns the style attribute of an element"
Run Code Online (Sandbox Code Playgroud)
'label'标签是一个dom元素.因此它具有"风格"属性.正如它在上面的w3schools链接中指出的那样,所有dom元素都具有"样式"属性.
事实上,我在这里设置(内联)标签标签的'style'属性- 这很好用:
<label for="itemImageId" style="color: gray" id="labelForImageUploadID">Item image</label>
Run Code Online (Sandbox Code Playgroud)
页面加载时标签文本颜色为灰色.
在一定条件下(用户已指示他们已准备好选择要上传的图像) - 我需要通过将上面的初始灰色文本颜色更改为黑色来将上传显示为"已启用".
我知道我可以使用css类来处理这个标签的文本颜色,并使用'className'属性动态地改变上面的css类吗?你敢打赌我做.今晚虽然我把这个DOM元素的脚抬起来了.我只需要一个'style'属性来改变(文本颜色)并且不想仅为它添加一个类 - 我在这里尝试的应该根据文档工作.
我想知道为什么我不能使用'style'属性,因为DOM说我可以 - "获取"和"设置"DOM元素的属性.
在这里,我"设置" - 我的"风格"属性 - 这没有 - 标签文本仍为灰色:
document.getElementById('labelForImageUploadID').style = "color: rgb(0,0,0)";
Run Code Online (Sandbox Code Playgroud)
这也不会将颜色从灰色变为黑色:
document.getElementById('labelForImageUploadID').style = "color: black";
Run Code Online (Sandbox Code Playgroud)
上述代码在页面上已经显示标签后执行(在javascript中),并且响应于表单上按钮的onclick事件,标签也是其中的一部分.
是否存在"设置"DOM元素的"样式"属性的错误?根据http://www.w3schools.com/jsref/dom_obj_all.asp,
"HTMLElement Object
The following properties, and methods can be used on all HTML elements."
(other properties here.....)
"style -- Sets or returns …
Run Code Online (Sandbox Code Playgroud) 我在这里学习模式,对PHP来说很新,所以我正在使用代码示例.请原谅我在这里使用'global',但我想了解php变量范围.
这是myGlobals.php:
<?php
global $db_server;
// other code not shown
?>
Run Code Online (Sandbox Code Playgroud)
这是connectToDb.php:
<?php
require_once 'myGlobals.php';
// no declared functions in this file, all inline code
$db_server = mysql_connect(.....);
mysql_select_db( "theDatabase", $db_server);
?>
Run Code Online (Sandbox Code Playgroud)
这是addDbRecords.php:
<?php
require_once 'myGlobals.php';
// other inline code.....
doAddDeleteRecord($db_server);
function doAddDeleteRecord($db_server)
{
//global $db_server;
if( !mysql_query($query, $db_server))
{
// handle the error...
}
}
?>
Run Code Online (Sandbox Code Playgroud)
这是index.php:
<?php
require_once 'myGlobals.php';
require_once 'connectToDb.php';
require_once 'addDbRecords.php';
// this is simplified, just trying to show that everything in inline code
?>
Run Code Online (Sandbox Code Playgroud)
这是问题所在.当我 …
以下代码适用于 FF,但不适用于 IE9:
// turn on the 'image file upload' field and its label
document.getElementById('itemImageId').disabled = false;
document.getElementById('labelForImageUploadID').style.color = "black";
Run Code Online (Sandbox Code Playgroud)
这是带有标签和文件输入的 HTML:
<label for="itemImageId" style="color: silver" id="labelForImageUploadID">Item image
(select to change the item's current image)</label>
<input type="file" size="100px" id="itemImageId" disabled="disabled"
name="theFileUpload"></input>
Run Code Online (Sandbox Code Playgroud)
** 编辑 ** 上面的标签和文件上传标签嵌套在下面的div 中——我添加了这个,这样你就可以看到鼠标点击是如何处理的。该handleRowClick()函数具有以上的JavaScript代码,试图打开文本黑色:
<div class="itemlistRowContainer" id="topmostDiv_ID" onclick="handleRowClick(this);"
onmouseover="handleMouseOver(this);" onmouseout="handleMouseOut(this);"
ondblclick="handleDblClick(this);">
Run Code Online (Sandbox Code Playgroud)
所以当这个标签第一次出现在页面上时,它的颜色是正确的——由于内联颜色样式,它是银色的。
然后上面的 Javascript 代码在鼠标点击时执行。
在Firefox中,Javascript代码将标签文本变成黑色,并启用文件上传控制。
但是在 IE9 中,标签的文本保持灰色。
IE9 不支持style.color = "somecolor" 动态控制标签标签的颜色?
我查看了其他一些帖子,我发现的唯一怪癖是,如果您动态启用/禁用,在尝试更改其颜色之前,请确保标签在 IE9 中已启用。
这不是这里的一个因素,因为代码永远不会禁用标签标签。
这不仅仅是一个 …
我在这里和网上查过这个问题,但没有找到答案。
由于我不会详细讨论的原因,我需要从 mysql 数据库表中删除顶行,然后刷新页面。
删除始终针对顶行,并且与行的内容无关,因此执行 select where 是没有用的。
在我看来我应该能够调用(在我的 php 代码中):
mysql_deleterow(0); // delete the top row from the table
Run Code Online (Sandbox Code Playgroud)
并完成它。但是哦不——我找不到这样的电话。
有没有办法只删除表行而不考虑其内容?(如果你想问我“你为什么要这么做?”,请重读上面我说的“原因我不会详细讨论”)
这里是全新的Android开发人员,也是Eclipse新手.
我下载并安装了
所有安装成功 - 我昨天(7/14/11)做了这个,所以我有最新的.
在Eclipse中,我选择"New Project",然后为项目类型选择"Android-> Android Project".
然后我进入Eclipse中的新项目窗口,它需要3件事:
1)项目名称 - 完成.我将我的第一个Android项目命名为"myAndroidOne"
2)我选择"在工作区中创建新项目"单选按钮
3)我为'Build target'选择'Android 2.2'
4)我接受Eclipse对'应用程序名称',"myAndroidOne"的建议
我不知道Eclipse在'Package Name'字段中想要什么.虽然我知道'Java包',但我很困惑Eclipse可能要我在这里指定一个Java包 - 毕竟,我正在创建一个新项目并且没有想法,对Android来说是全新的,如果我将使用的任何Java包.
我尝试输入"pkgMyAndroidOne",但"下一步"按钮不亮.
我无法创建一个全新的Android项目 - 我还没有编写一行代码,我只是想创建一个Eclipse Android项目来开始自学如何编写我的第一个Android应用程序.
Eclipse想要什么?
Here is a div block that appears fine as part of a top row of 5 nearly-identical divs that make up a Nav bar at the top of my page -- although there are 5 of the divs like the one I show here with an anchor, I'm only showing the one that goes on the far right end of the Nav bar for my "User Dashboard" link:
<div class="pageTopRowContainer"> // this is the containing div for all 5 of …
Run Code Online (Sandbox Code Playgroud)