我很享受YARD的使用:
http://code.google.com/p/yardparser/
http://www.codeproject.com/KB/recipes/yard-tokenizer.aspx
我能够构建全功能计算器.我正在评估YARD做PHP解析器.请关注PEG语法和解析器生成器的局限性.非常感谢你!
刚刚得知Laravel内部使用了nikic phpparser.
我修改了我的代码,以便在其中一个条件下发送电子邮件并开始死亡.
PHP日志显示了这个:
[Sat Oct 03 21:18:23 2015] [错误] [client xx.xx.xx.xx] PHP致命错误:/ home/yyyy/public_html /中允许的内存大小为33554432字节(尝试分配1048576字节)供应商/ nikic/PHP的解析器/ LIB/PHPParser/NodeTraverser.php上线66,引荐:http://yyyy.com/home
我暂时增加了内存以解决问题.
但是,我想摆脱创可贴.
我看到NodeTraverser函数正在进行克隆,这会导致问题:
protected function traverseNode(PHPParser_Node $node)
{
ini_set('memory_limit', '64M'); // temporary fix
$node = clone $node;
foreach ($node->getSubNodeNames() as $name) {
$subNode =& $node->$name;
if (is_array($subNode)) {
$subNode = $this->traverseArray($subNode);
} elseif ($subNode instanceof PHPParser_Node) {
foreach ($this->visitors as $visitor) {
if (null !== $return = $visitor->enterNode($subNode)) {
$subNode = $return;
}
}
$subNode = $this->traverseNode($subNode);
foreach ($this->visitors as $visitor) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试将html表行保存到php数组中,然后将数组保存在数据库中.
<form action="" method="post">
<table class="widefat" id="theTable">
<thead>
<tr>
<th>Level Identifier</th>
<th>Non-logged in message</th>
<th>Logged in message</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" value="" style="height: 19px;background-color: white;font-size:10px;"/></td>
<td><textarea style="font-size:10px;" name="promo_msg_free" cols="43" rows="1">This is your custom message template</textarea></td>
<td><textarea style="font-size:10px;" name="promo_msg_free" cols="43" rows="1">This is your custom message template</textarea></td>
</tr>
<tr>
<td><input type="text" value="" style="height: 19px;background-color: white;font-size:10px;"/></td>
<td><textarea style="font-size:10px;" name="promo_msg_free" cols="43" rows="1"></textarea></td>
<td><textarea style="font-size:10px;" name="promo_msg_free" cols="43" rows="1"></textarea></td>
</tr>
</tbody>
</table>
</form>
Run Code Online (Sandbox Code Playgroud)
我如何检索每个行数据并将其保存到数组元素,最后我将数组保存到数据库?谢谢
我认为这是一个简单的问题,但我已经做了我所知道的但仍然没有工作.我想从这个链接获得输出:
您可以在浏览器上粘贴并查看它.有一些文字输出.我试过PHP中的一些函数,比如file_get_contents和curl.我没有使用ajax或JavaScript,因为我不熟悉它.最后,我正在与XAMPP合作.
我在php中解析html,因为我无法控制原始内容,我想删除样式和不必要的标签,同时仍保留内容和标签的简短列表,即:
p,img,iframe(也许还有其他一些)
我知道我可以删除一个给定的标签(参见我在下面使用的代码),但由于我不一定知道它们可能是什么标签,而且我不想创建一个巨大的可能列表,我会喜欢除了我允许的列表之外能够删除所有内容.
function DOMRemove(DOMNode $from) {
$sibling = $from->firstChild;
do {
$next = $sibling->nextSibling;
$from->parentNode->insertBefore($sibling, $from);
} while ($sibling = $next);
$from->parentNode->removeChild($from);
}
$dom = new DOMDocument;
$dom->loadHTML($html);
$nodes = $dom->getElementsByTagName('span');
Run Code Online (Sandbox Code Playgroud) 我需要一个可以在文件中找到PHP代码块的REGEX.例如:
<? print '<?xml version="1.0" encoding="UTF-8"?>';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<?php echo "stuff"; ?>
</head>
<html>
Run Code Online (Sandbox Code Playgroud)
当REGEX解析时会返回:
array(
"<? print '<?xml version=\"1.0\" encoding="UTF-8"?>';?>",
"<? echo \"stuff\"; ?>"
);
Run Code Online (Sandbox Code Playgroud)
您可以假设PHP有效.
我在论坛中使用SCEditor 。我设法将 bbcodes 插入数据库。但是当我尝试在页面中显示代码时,bbcodes 显示时没有样式。没有html,没有样式。只有坏的 bbcodes。我在其文档页面中调查了很长时间,但没有找到任何 php 解析器。这是屏幕截图。
请问,你能帮我吗,如何在 PHP 中将 bbcode 解析为 html?
php-parser ×7
php ×5
html-parsing ×2
bbcode ×1
curl ×1
dom ×1
domdocument ×1
editor ×1
file ×1
html ×1
laravel ×1
parsing ×1
peg ×1
regex ×1
yard ×1