这让我疯狂......我只想添加另一个img
节点.
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<gallery>
<album tnPath="tn/" lgPath="imm/" fsPath="iml/" >
<img src="004.jpg" caption="4th caption" />
<img src="005.jpg" caption="5th caption" />
<img src="006.jpg" caption="6th caption" />
</album>
</gallery>
XML;
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($xml);
$album = $xmlDoc->getElementsByTagname('album')[0];
// Parse error: syntax error, unexpected '[' in /Applications/XAMPP/xamppfiles/htdocs/admin/tests/DOMDoc.php on line 17
$album = $xmlDoc->getElementsByTagname('album');
// Fatal error: Call to undefined method DOMNodeList::appendChild() in /Applications/XAMPP/xamppfiles/htdocs/admin/tests/DOMDoc.php on line 19
$newImg = $xmlDoc->createElement("img");
$album->appendChild($newImg);
print $xmlDoc->saveXML();
Run Code Online (Sandbox Code Playgroud)
错误:
我想知道这是否可行?
我想创建一个跨平台的Flash投影仪和文件,然后从中创建一个ISO供用户下载.
到目前为止谷歌并没有给我太多帮助......
我现在很难用PHP的gettext()函数进入翻译文件并用Poedit创建文件.Poedit也没有附带帮助文件,我尝试了许多在线发现但没有任何作用的东西..我在Mac OSX上使用XAMPP配置.
在OSX上,我的XAMPP目录是
/Applications/XAMPP/xamppfiles/htdocs/
Run Code Online (Sandbox Code Playgroud)
在这个目录里面我创建了gettext.php
<?php echo _("Hello World"); ?>
Run Code Online (Sandbox Code Playgroud)
和以下文件夹:
/locale/
/locale/it_IT/LC_MESSAGES/
Run Code Online (Sandbox Code Playgroud)
当我做的时候使用Poedit>文件>新目录
语言:意大利语
国家:意大利
Charset:UTF-8
源代码字符集:UTF-8
基本路径:/ Applications/XAMPP/xamppfiles/htdocs /
比我将default.po保存到/ locale/it_IT/LC_MESSAGES /
"更新目录失败.点击'更多>>'了解详情
13:04:10: Poedit did not find any files in scanned directories.
13:04:11: Entries in the catalog are probably incorrect.
13:04:11: Updating the catalog failed. Click on 'More>>' for details.
Run Code Online (Sandbox Code Playgroud) 我正在我的网站上从localhost(http://172.16.65.1/)在OSX上运行MAMP服务器.
我想从谷歌加载一些JSON,一些简单的测试告诉我这里有一个问题..
echo file_get_contents("http://www.google.com"); // FAILS
// PHP log: [07-Dec-2011 23:09:21] PHP Warning: file_get_contents(http://www.google.com) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Host is down in /Applications/MAMP/htdocs/-tests/get-json.php on line 3
echo file_get_contents("http://www.yahoo.com"); // FAILS
// echo file_get_contents("http://localhost"); // WORKS
// echo file_get_contents("http://172.16.65.1/"); // WORKS - My MAMP server
Run Code Online (Sandbox Code Playgroud)
我该怎么办?它在我的主机提供商服务器上工作正常.
相当尴尬我花了多少时间试图从按钮下载一个zipfile ....
<button type='button' id='button-download'>download zipfile</button>
$("#button-download").live("click", function() {
$.get("http://localhost/admin/zip/002140.zip"); // doesn't work?
})
Run Code Online (Sandbox Code Playgroud)
我需要一些子弹证明,这就是我在这里问的原因,谢谢.
我有两个列表,我希望它们都可以排序,并希望能够将项目从list1复制(拖动)到list2,反之亦然.
http://jqueryui.com/demos/sortable/#connect-lists
是我想要的,但项目是移动,而不是复制.我用draggables和droppables做了一些实验,但是我无法让它们保持可排序.例如:http://jsfiddle.net/tunafish/dvXmf/
我该怎么做呢?
function myUIEvent() {
var iCheckFcn = "isInFavorites";
var itemSrc = ui.item.find("img").attr("src");
if (eval(iCheckFcn(itemSrc))) { alert("it's a favorite"); }
function isInFavorites(url) { return true; } // returns boolean
Run Code Online (Sandbox Code Playgroud) 我有这一行缩略图,我用jQuery动画.
这些缩略图中的每一个都有一个悬停和活动类.
它们工作正常但是当我为列表设置动画时,鼠标光标下的新缩略图不会应用悬停?每次点击后我都要移动鼠标一点点?
这有点困难.我在这里做了一个小提琴:http://jsfiddle.net/nZGYA/
当你开始点击拇指3而不移动鼠标你就会明白我的意思...
它在FireFox中运行良好,而不是Safari,Chrome,IE等.
我可以做些什么吗?
这里参考我的代码:
<style type="text/css">
.container { position: relative; overflow: hidden; width: 140px; height: 460px; float: left; margin-right: 100px; background: silver; }
ul { position: absolute; top: 10; list-style: none; margin: 10px; padding: 0; }
li { margin-bottom: 10px; width: 120px; height: 80px; background: gray; }
#list-2 li a { display: block; width: 120px; height: 80px; outline: none; }
#list-2 li a:hover { background: teal; }
#list-2 li a.active { background: navy; …
Run Code Online (Sandbox Code Playgroud) 有人解释我,当我把所有东西都设置为UTF-8时,我会继续得到那些该死的
MySQL
服务器版本:5.1.44
MySQL字符集:UTF-8 Unicode(utf8)
我创建了一个新的数据库
name:utf8test
collation:utf8_general_ci
MySQL连接排序规则:utf8_general_ci
我的SQL看起来像这样:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `test_table` (
`test_id` int(11) NOT NULL,
`test_text` text NOT NULL,
PRIMARY KEY (`test_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `test_table` (`test_id`, `test_text`) VALUES
(1, 'hééélo'),
(2, 'wööörld');
Run Code Online (Sandbox Code Playgroud)
我的PHP/HTML:
<?php
$db_conn = mysql_connect("localhost", "root", "") or die("Can't connect to db");
mysql_select_db("utf8test", $db_conn) or die("Can't select db");
// $result = mysql_query("set names 'utf8'"); // this works... why??
$query = "SELECT * FROM test_table";
$result = …
Run Code Online (Sandbox Code Playgroud) 不是一个问题,而是一种挑战..
我有这个PHP函数,我总是使用,现在我需要它在Javascript中.
function formatBytes($bytes, $precision = 0) {
$units = array('b', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
Run Code Online (Sandbox Code Playgroud)
编辑:感谢回复,我提出了更短的内容,但没有精确(如果你有一些想法,请告诉我)
function format_bytes(size){
var base = Math.log(size) / Math.log(1024);
var suffixes = ['b', 'KB', 'MB', 'GB', 'TB' , 'PB' , 'EB'];
return Math.round(Math.pow(1024, base - Math.floor(base)), 0) + ' ' + suffixes[Math.floor(base)]; …
Run Code Online (Sandbox Code Playgroud)