1

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

i alarmed alien
  • 9,412
  • 3
  • 27
  • 40
Schwann
  • 167
  • 1
  • 1
  • 13

1 Answers1

1

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.

danmullen
  • 2,556
  • 3
  • 20
  • 28
  • shouldn't matter. php's variable scope is function-level. both paths of the if() are setting a value, so no matter what the if() evaluates to, the variable's going to get something set. – Marc B Oct 22 '14 at 18:27