Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果PHP出现问题,则结束 编辑**_Php_If Statement - Fatal编程技术网

如果PHP出现问题,则结束 编辑**

如果PHP出现问题,则结束 编辑**,php,if-statement,Php,If Statement,您好,我是PHP新手,正在尝试找出Joomla模块的破解方法 由于某些原因,“else”语句不起作用。我不明白为什么 <? if (KRequest::get('get.view', 'string') != 'event' || isset($module)) : ?> <? $desc = $event->description; ?> <? $desc = preg_replace("/\{[^\)]+\

您好,我是PHP新手,正在尝试找出Joomla模块的破解方法

由于某些原因,“else”语句不起作用。我不明白为什么

        <? if (KRequest::get('get.view', 'string') != 'event'  || isset($module)) : ?>
        <? $desc = $event->description; ?>
        <? $desc = preg_replace("/\{[^\)]+\}/","", $desc) ?>

        <? $desc = substr(strip_tags($desc, '<p><ul><li><b><i><strong><br>'), 0, 180)?>
        <? if (strlen($desc) == 180) $desc .= '...'; ?>
        <div itemprop="description" class="ohanah-event-short-description">
        <?=$desc?>
        </div>
    <? else : ?>
    <!--here is where I want to end it --!>No description.


        <?
        $description = $event->description;

        // Create temporary article
        $item =& JTable::getInstance('content');
        $item->parameters = new JParameter('');
        $item->text = $description;

        $joomlaVersion = JVersion::isCompatible('1.6.0') ? '1.6' : '1.5';
        if ($joomlaVersion == '1.5') { 
            $results = JFactory::getApplication()->triggerEvent('onPrepareContent', array (&$item, &$params, 1));
        } else {
            $dispatcher = JDispatcher::getInstance();
            JPluginHelper::importPlugin('content');
            $results = $dispatcher->trigger('onContentPrepare', array ('com_content.article', &$item, &$params, 1));
        }   
        $description = $item->text;     
        ?>
        <div style="display:none"><span itemprop="name"><?=$event->title?></span></div>
        <div itemprop="description" class="full-description">
        <?=$description?>
        </div>
    <? endif ?>

这就是你的全部密码吗?你需要结束语

这样说,考虑卷曲括号语法,我发现用.</P>避免错误更容易。 另一方面,当每一行都是PHP时,您不必在每一行上都有,您可以让PHP块在几行之间保持打开状态

<?php
if (...) {
    // stuff
} else {
    // other stuff
}
?>
如果我理解您的代码流,它将如下所示

<?php
if (KRequest::get('get.view', 'string') != 'event'  || isset($module)) {
    $desc = $event->description;
    $desc = preg_replace("/\{[^\)]+\}/","", $desc)

    $desc = substr(strip_tags($desc, '<p><ul><li><b><i><strong><br>'), 0, 180)
    if (strlen($desc) == 180) {
        $desc .= '...';
    }
?>
    <div itemprop="description" class="short-description">
<?php echo $desc; ?>
    </div>
<?php } else { ?>
    No description.
<?php } ?>

我只是在猜测,但是您不需要删除IF语句中的分号来告诉解析器仍然存在else块吗

if (strlen($desc) == 180) $desc .= '...'

支架是错的。应该是这样或类似的-不确定您需要$desc的位置:

if (strlen($desc) == 180)
{
    $desc .= '...';
    echo '<div itemprop="description" class="short-description">';
    echo $desc;
    echo '</div>';
}
else
{
    echo 'No description.';
}

我看不到任何结尾。你确定这是所有相关的代码吗?不工作不是对预期和观察到的行为的描述,你的文章标题绝对是垃圾。不。我相信,通过研究逻辑,else应该与第一个if相匹配。第二,如果只是一次断章取义的尝试,它会忘记截短一个很长的描述,就像你的坟墓一样,即使它是一个骗局。你会这样认为吗?但我们说的是Joomla编码器。哇!令人不寒而栗的是,我错过了原始代码的完整部分。完整的东西现在就在那里……非常感谢!完美的作品!: