Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 图像标记中的ID失败_Php_Html_Key Value - Fatal编程技术网

Php 图像标记中的ID失败

Php 图像标记中的ID失败,php,html,key-value,Php,Html,Key Value,尝试设置id=$x-但失败 <img src='images/Rename.png' id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'> 它在Firebug中显示id=1 为什么我不能将img标签中的id设置为任何值 以下是正确的语法 for ($x=0; $x<100; $x++) { echo "<input ty

尝试设置
id=$x
-但失败

<img src='images/Rename.png' id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>
它在Firebug中显示id=1


为什么我不能将img标签中的id设置为任何值

以下是正确的语法

for ($x=0; $x<100; $x++) {
   echo "<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>";
}

用于($x=0;$x这是一个不错的答案,除了ID的“可能”不应该以数字开头。以“-”或“可能”开头是可以的。以字母开头是最安全的。是的,它是正确的。但是我希望和而不是@osomanden CSS ID不能以数字开头。-但是它们可以包含数字,所以请以字母作为前缀。@JAL让我们只-为了论证,-说我意识到了这一点,并且试图不管它,设置一个ID=SoMeValue.如果我在一个输入标签上做的话,ID被正确地设置(即使我用eg. A.预置它,所以我只是用前缀来尝试它:代码:它仍然在显示——如果你认为我的答案是正确的,你能把它标记为正确吗?
for ($x=0; $x<100; $x++) {
   echo "<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>";
}