Search code examples
phpopencartvqmod

PHP Notice: Undefined variable: http_type


I get the following PHP Notice in my opencart log file.

Undefined variable: http_type in /home/AAA/public_html/vqmod/vqcache/vq2-catalog_view_theme_template_product_product.tpl on line 3

Here is what I have in my product.php file's few first few lines

<?php if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
    $http_type = "https:";} else {$http_type = "http:";} 
<!---THIS IS LINE 3--->  ?>    
    <?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
    <div id="content"><?php echo $content_top; ?> 
      <div class="breadcrumb" xmlns:v="<?php echo $http_type;?>//rdf.data-vocabulary.org/#" id="brd-crumbs"  >     
        <ul>
            <?php foreach ($breadcrumbs as $breadcrumb) { ?>
                <li typeof="v:Breadcrumb">
                <?php echo $breadcrumb['separator']; ?><a property="v:title" rel="v:url" href="<?php echo $breadcrumb['href']; ?>"><span><?php echo $breadcrumb['text']; ?></span></a></li>
            <?php } ?>
        </ul>
      </div>

Any help is highly appreciated


Solution

  • Firstly, it's just a notice so I expect everything is working as you would expect.

    The notice is generated because when the $http_type variable is echoed, it hasn't necessarily been set to anything. If you add $http_type = ''; before the initial if statement, that will get rid of the notice.