嘿伙计们我目前正在做一些关于PhP的工作,需要我使用该yaml_parse_file()函数来解析YAML文件.我仍然是该语言的新手,当我在Windows上未经修改的XAMPP服务器上尝试使用该功能时,我得到错误'找不到功能'.经过一些研究后我发现你实际上应该在你的php安装上安装扩展才能使用该功能.http://php.net/manual/en/yaml.setup.php这个链接详细介绍了安装过程,我已经阅读了它但是我对安装过程感到困惑.上面的链接声明没有可用于下载的DLL包,但注释直接到此链接http://pecl.php.net/package/yaml,您可以在其中清楚地看到YAML Parser的DLL包.我的问题是,如果你能告诉我如何使用XAMPP在Windows机器上执行此安装过程.
编辑:https://code.google.com/p/php-yaml/wiki/InstallingWithPecl此链接可能会为您提供有关此主题的更多信息,但我无法理解它是如何工作的:(
Edit2:我试图下载上面链接上给出的DLL并将其添加到我的php/ext文件夹并在php.ini中添加一个条目extension=php_yaml.dll但是当我尝试测试我的扩展是否已被以下脚本加载时,我得到了一个错误.
<?php
if (extension_loaded(yaml))
echo "yaml loaded :)";
else
echo "something is wrong :(";
?>
Run Code Online (Sandbox Code Playgroud) 我有一个数据库,analy.php和index.php网页.analysis.php从数据库中获取数据,按所需模式对其进行排序,然后使用id"data"将其回显json_encode($array);为a div.我试图获取该JSON数据并在index.php页面中解析它.
但是我收到了一个错误. SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
每次用户从选择框中选择一个选项时,我都会尝试获取此数据.
我的jQuery代码是:
$(document.body).on('change', '.select' , function () {
var identification = $(this).val();
var JSONText = $(this).closest('div[id|="module"]').find('p[id="JSON"]');
JSONText.load('analysis.php?data=' + identification + ' #data');
console.log("JSON Imported: '" + identification + "'");
var obj = jQuery.parseJSON(JSONText.text());
console.log(JSONText.text());
});
Run Code Online (Sandbox Code Playgroud)
编辑:你可以看到我有片段console.log(JSON.text());.我得到的JSON输出是正确的.我认为唯一的问题是引号全部"而不是JSON引号与外引号不同.
如果我创建一个类,并将其对象放在一个函数*中.一旦函数结束了我创建的对象发生了什么?它被删除了吗?
编辑:*我从主要调用该函数
class foo{
vector<foo*>* queue;
vector<int> pos;
foo(vector<foo*>* queue, vector<int> pos){
this->queue=queue;
this->pos=pos;
}
public:
foo(vector<foo*>* queue){
this->queue=queue;
}
void init(){
vector<int> posNew = pos;
//Create Binary Tree Children of the state FOO
posNew.push_back(/* An Additional Value*/)
foo newFoo(queue, posNew);
queue->push_back(&newFoo);
}//Here the variables newFoo and posNew are out of scope so they are deleted even from the queue
}
class bar{
vector<foo*> queue; //Assume that queue has a root node added to it.
bar(){
for(unsigned int i=0; i<queue.size();i++){
queue[i]->init();// Somewhere …Run Code Online (Sandbox Code Playgroud)