Welcome Guest, Not a member yet? Register   Sign In
Can someone check base_url() and base_url("param")
#3

@SteveDroz,

This is the View script
PHP Code:
<?php declare(strict_types=1);

$aLinksTop = [
  'home'        => 'Home',
  'bwci4'       => 'Built with CI4',
  'playground'  => 'Playground',
  'info'        => 'Info',
  'lhost'       => 'Localhost',
];

  $sLinksTop ''
  foreach($aLinksTop as $key => $link) :
    $URL base_url() .'/' .$key;
   
    $current 
=($key === $uri->getSegment(1'home') )
          ' current '  
          
''
          ;

    $tmp = <<< ____EOT
    \n
    <a class="
$key $current"  href="$URL"> $link </a> 
____EOT;
    $sLinksTop .= $tmp;
  endforeach; 


The above script $URL is correct and displays:

Quote:$URL = base_url() .'/' .$key;
==>
http://localhost/ci4-strict.tk/public_html/home
http://localhost/ci4-strict.tk/public_html/bwci4
http://localhost/ci4-strict.tk/public_html/playground
http://localhost/ci4-strict.tk/public_html/info
http://localhost/ci4-strict.tk/public_html/lhost

Using this script in accordance with the manual produces:
Quote:$URL = base_url($key);
==>
http://localhost/ci4-strict.tk/public_ht..._html/home
http://localhost/ci4-strict.tk/public_ht...html/bwci4
http://localhost/ci4-strict.tk/public_ht...playground
http://localhost/ci4-strict.tk/public_ht..._html/info
http://localhost/ci4-strict.tk/public_ht...html/lhost
Reply


Messages In This Thread
RE: Can someone check base_url() and base_url("param") - by John_Betong - 09-06-2020, 11:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB