Search code examples
phphtmlstringcodeigniterbase-url

How to use base URL inside number and character in PHP?


I have base URL which is http://localhost/test/. I have an anchor tag called as Click me. I checked in view source It is displaying like

`<a href='http://localhost/test/abdah.0`p)dp'>Click me</a>` 

It should be displayed like

`<a href='http://localhost/test/index.php/example/index/4&action=print'>Click me</a>`

I tried code but is it not working.

<?php
      $session_stud_id=4;
      $bg_url='index.php/example/index/'.$session_stud_id;
      $action_url="action=print"; 
      echo $main_url=$bg_url&$action_url;//output abdah.0`p)dp 
      ?>
  <a href="<?php echo base_url($main_url);?>" >Click me</a>

I am getting some garbage value something like this abdah.0p)dp`. Would you help me out in this?


Solution

  • You have to concatenate multiple string using . change your main_url to :

    echo $main_url=$bg_url."&".$action_url;