首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TWIG和“意外T_FUNCTION”,它们用hostmonster.com返回服务器500错误

TWIG和“意外T_FUNCTION”,它们用hostmonster.com返回服务器500错误
EN

Stack Overflow用户
提问于 2015-12-15 12:06:29
回答 1查看 112关注 0票数 3

我有这个代码,它可以在我的本地主机和one.com网络主机上工作。但是当上传到hostmonster.com的ftp时,浏览器会返回一个500错误。我用树枝做模板引擎。

以下是这些页面的链接:

  • 不工作(hostmonster.com):http://armourertech.com/produit.php
  • 工作(one.com):http://chacartz.fr/autre/armourer/produit.php

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

$walkdir_gearbox = new Twig_SimpleFilter ( 'walkdir_gearbox', function ($path_01)

代码:

代码语言:javascript
复制
<?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中:

代码语言:javascript
复制
{{ 'twig' |walkdir_gearbox }}

下面是error.log文件的最后一行

代码语言:javascript
复制
[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

是否有解决方案,还是被迫更改提供者?

EN

回答 1

Stack Overflow用户

发布于 2015-12-15 15:23:03

删除最后一行的"()“,改为:

代码语言:javascript
复制
echo $twig->render('produit.html');

另外,请检查PHP版本:匿名函数只允许在PHP5.3.0和更高版本上使用参数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34288849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档