How to resolve : “Undefined variable: crumb” error with openclassifieds

Recently on our website which uses openclassifieds scripts for classifieds, we started getting following errors,

 Undefined variable: crumb 

When we looked at other error logs, we see following errors along with the above primarily visible error in browser,

2018-01-31 10:00:26 — ERROR: ErrorException [ 8 ]: Undefined variable: content ~ APPPATH/common/views/alert_terms.php [ 9 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110
2018-01-31 10:00:26 — ERROR: ErrorException [ 8 ]: Undefined variable: data ~ DOCROOT/themes/reclassifieds3/views/header.php [ 36 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110
2018-01-31 10:00:26 — ERROR: ErrorException [ 8 ]: Undefined variable: crumb ~ APPPATH/common/views/breadcrumbs.php [ 7 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110
2018-01-31 10:00:31 — ERROR: Kohana_Exception [ 0 ]: Required route parameter not passed: category ~ APPPATH/kohana/system/classes/Kohana/Route.php [ 572 ] in oc/kohana/system/classes/Kohana/Kohana/Exception.php:110

When we looked at the code, at oc/common/views/breadcrumbs.php its as below,

<?php defined('SYSPATH') or die('No direct script access.');?>
<? if (count($breadcrumbs) > 0) : ?>
        <ul class="breadcrumb">
        <? foreach ($breadcrumbs as $crumb) : ?>
                <? if ($crumb->get_url() !== NULL) :  ?>
                                <a title="<?=HTML::chars($crumb->get_title())?>" href="<?=$crumb->get_url()?>"><?=$crumb->get_title()?></a>
                <? else : ?>
                        <li class="active"><?=$crumb->get_title()?></li>
                <? endif; ?>
        <?endforeach; ?>
<? endif; ?>

So, from code its clear that, the error comes from the php code, like

 <li class="active"><?=$crumb->get_title()?></li> 

which shows its not able to identify crumb veriable, so for try, we removed “=” from before $crumb and the error went, but this is not the correct implementation, so when we further searched into internet, we found that


is required to have get the variable output. and this =$crumb is nothing but the short form of “echo $crumb” and its further detailed as like below,

short_open_tag boolean
Tells PHP whether the short form (<? ?>) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>. Also, if disabled, you must use the long form of the PHP open tag (<?php ?>).

This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available.

Reference : php manual

Related :   Solved : fatal error: pcap.h: No such file or directory

hence to make sure


works well, we need to enable short_open_tag from php.ini so, the final solution is add following line into php.ini

 vim php.ini 

and make sure you have following line,

 short_open_tag = On 

If you are using shared hosting of some servers, the php.ini file will be present in /home/your_user_name/public_html/php.ini

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question