gpt4 book ai didi

TWIG 和 "unexpected T_FUNCTION"返回 hostmonster.com 的服务器 500 错误

转载 作者:行者123 更新时间:2023-12-04 09:31:33 24 4
gpt4 key购买 nike

我有这段代码可以在我的本地主机和 one.com 虚拟主机上运行。但是在hostmonster.com的ftp上传时,浏览器返回500错误。我使用 TWIG 作为模板引擎。

页面链接如下:

hostmonster.com 的技术人员告诉我错误在第 12 行:

$walkdir_gearbox = new Twig_SimpleFilter ( 'walkdir_gearbox', 函数 ($path_01)

代码:

<?php 

require "twig.php";
require "nav.php";
$head_title = "armourertech";
$nav['produit'] = "actuel";
$keywords = "";
$description = "";
$robots = "index, follow";
$googlebot = "index, follow";


$walkdir_gearbox = new Twig_SimpleFilter ( 'walkdir_gearbox', function ($path_01) {//<-line 12
$path_01 = "img/x-hightech/01gearbox";
$d = new DirectoryIterator($path_01);
foreach($d as $f) {
if(
preg_match('/(\.gif|\.png|\.jpe?g)$/', $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
$file = basename($f, ".jpg");
echo "<figure itemprop=\"associatedMedia\" itemscope itemtype=\"http://schema.org/ImageObject\"><a href=\"img/x-hightech/01gearbox/".$f->getFilename() . "\" itemprop=\"contentUrl\" data-size=\"".$w."x".$h."\"><img src=\"img/x-hightech/thumbs/01gearbox/".$f->getFilename() . "\" itemprop=\"thumbnail\" alt=\"".$file." - ARMOURERTECH\" /></a><figcaption itemprop=\"caption description\">".$file."</figcaption></figure>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkdir_gearbox($f->getPathname());
}
}
});

$walkdir_gearboxcnc = new Twig_SimpleFilter ( 'walkdir_gearboxcnc', function ($path_02) {
$path_02 = "img/x-hightech/02fabrication-gearbox-cnc";
$d = new DirectoryIterator($path_02);
foreach($d as $f) {
if(
preg_match('/(\.gif|\.png|\.jpe?g)$/', $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
$file = basename($f, ".jpg");
echo "<figure itemprop=\"associatedMedia\" itemscope itemtype=\"http://schema.org/ImageObject\"><a href=\"img/x-hightech/02fabrication-gearbox-cnc/".$f->getFilename() . "\" itemprop=\"contentUrl\" data-size=\"".$w."x".$h."\"><img src=\"img/x-hightech/thumbs/02fabrication-gearbox-cnc/".$f->getFilename() . "\" itemprop=\"thumbnail\" alt=\"".$file." - ARMOURERTECH\" /></a><figcaption itemprop=\"caption description\">".$file."</figcaption></figure>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkdir_gearboxcnc($f->getPathname());
}
}
});

$walkdir_piston = new Twig_SimpleFilter ( 'walkdir_piston', function ($path_03) {
$path_03 = "img/x-hightech/03piston-gear-set";
$d = new DirectoryIterator($path_03);
foreach($d as $f) {
if(
preg_match('/(\.gif|\.png|\.jpe?g)$/', $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
$file = basename($f, ".jpg");
echo "<figure itemprop=\"associatedMedia\" itemscope itemtype=\"http://schema.org/ImageObject\"><a href=\"img/x-hightech/03piston-gear-set/".$f->getFilename() . "\" itemprop=\"contentUrl\" data-size=\"".$w."x".$h."\"><img src=\"img/x-hightech/thumbs/03piston-gear-set/".$f->getFilename() . "\" itemprop=\"thumbnail\" alt=\"".$file." - ARMOURERTECH\" /></a><figcaption itemprop=\"caption description\">".$file."</figcaption></figure>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkdir_piston($f->getPathname());
}
}
});

$walkdir_cylindre = new Twig_SimpleFilter ( 'walkdir_cylindre', function ($path_04) {
$path_04 = "img/x-hightech/04tete-cylindre";
$d = new DirectoryIterator($path_04);
foreach($d as $f) {
if(
preg_match('/(\.gif|\.png|\.jpe?g)$/', $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
$file = basename($f, ".jpg");
echo "<figure itemprop=\"associatedMedia\" itemscope itemtype=\"http://schema.org/ImageObject\"><a href=\"img/x-hightech/04tete-cylindre/".$f->getFilename() . "\" itemprop=\"contentUrl\" data-size=\"".$w."x".$h."\"><img src=\"img/x-hightech/thumbs/04tete-cylindre/".$f->getFilename() . "\" itemprop=\"thumbnail\" alt=\"".$file." - ARMOURERTECH\" /></a><figcaption itemprop=\"caption description\">".$file."</figcaption></figure>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkdir_cylindre($f->getPathname());
}
}
});

$walkdir_hopup = new Twig_SimpleFilter ( 'walkdir_hopup', function ($path_05) {
$path_05 = "img/x-hightech/05hopup";
$d = new DirectoryIterator($path_05);
foreach($d as $f) {
if(
preg_match('/(\.gif|\.png|\.jpe?g)$/', $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
$file = basename($f, ".jpg");
echo "<figure itemprop=\"associatedMedia\" itemscope itemtype=\"http://schema.org/ImageObject\"><a href=\"img/x-hightech/05hopup/".$f->getFilename() . "\" itemprop=\"contentUrl\" data-size=\"".$w."x".$h."\"><img src=\"img/x-hightech/thumbs/05hopup/".$f->getFilename() . "\" itemprop=\"thumbnail\" alt=\"".$file." - ARMOURERTECH\" /></a><figcaption itemprop=\"caption description\">".$file."</figcaption></figure>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkdir_hopup($f->getPathname());
}
}
});

$walkdir_autre = new Twig_SimpleFilter ( 'walkdir_autre', function ($path_06) {
$path_06 = "img/x-hightech/06autres";
$d = new DirectoryIterator($path_06);
foreach($d as $f) {
if(
preg_match('/(\.gif|\.png|\.jpe?g)$/', $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
$file = basename($f, ".jpg");
echo "<figure itemprop=\"associatedMedia\" itemscope itemtype=\"http://schema.org/ImageObject\"><a href=\"img/x-hightech/06autres/".$f->getFilename() . "\" itemprop=\"contentUrl\" data-size=\"".$w."x".$h."\"><img src=\"img/x-hightech/thumbs/06autres/".$f->getFilename() . "\" itemprop=\"thumbnail\" alt=\"".$file." - ARMOURERTECH\" /></a><figcaption itemprop=\"caption description\">".$file."</figcaption></figure>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkdir_autre($f->getPathname());
}
}
});

$twig = new Twig_Environment($loader);
$twig->addFilter($walkdir_gearbox);
$twig->addFilter($walkdir_gearboxcnc);
$twig->addFilter($walkdir_piston);
$twig->addFilter($walkdir_cylindre);
$twig->addFilter($walkdir_hopup);
$twig->addFilter($walkdir_autre);
echo $twig->render('produit.html', array(
'nav' => $nav,
'head_title' => $head_title,
'keywords' => $keywords,
'description' => $description,
'robots' => $robots,
'googlebot' => $googlebot
)
);

?>

然后我将这一行放在 html 中:

{{ 'twig' |walkdir_gearbox }}

这是 error.log 文件的最后几行

[15-Dec-2015 03:15:45] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/imagick.so' - /usr/php/54/usr/lib64/php/modules/imagick.so: undefined symbol: zend_new_interned_string in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/http.so' - /usr/php/54/usr/lib64/php/modules/http.so: undefined symbol: zend_new_interned_string in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Warning: PHP Startup: magickwand: Unable to initialize module
Module compiled with module API=20100525, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/mailparse.so' - /usr/php/54/usr/lib64/php/modules/mailparse.so: undefined symbol: zend_new_interned_string in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/oauth.so' - /usr/php/54/usr/lib64/php/modules/oauth.so: undefined symbol: zend_new_interned_string in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/oci8.so' - /usr/php/54/usr/lib64/php/modules/oci8.so: undefined symbol: zend_new_interned_string in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/php/54/usr/lib64/php/modules/uploadprogress.so' - /usr/php/54/usr/lib64/php/modules/uploadprogress.so: undefined symbol: zend_ini_string_ex in Unknown on line 0

[15-Dec-2015 03:15:45] PHP Parse error: syntax error, unexpected T_FUNCTION in /home8/armourer/public_html/produit.php on line 12

是否有解决方案或我是否被迫更换供应商?

最佳答案

删除最后一行的“()”,应为:

echo $twig->render('produit.html');

此外,请检查 PHP 版本:匿名函数作为参数仅在 PHP 5.3.0 及更高版本上允许。

关于TWIG 和 "unexpected T_FUNCTION"返回 hostmonster.com 的服务器 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34288849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com