1
echo '<br /><a href=''.base_url().'home/do_logout'>Logout Fool!</a>';

What did I missed out in above concatenation?

I got this error

Message: syntax error, unexpected ''.base_url()."home/do_logout'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'
3
  • 2
    you should use and IDE with highlight syntax like netbean Commented Nov 20, 2014 at 2:36
  • 1
    Hope my answer can help you out! Also if your interested to take a tour about SO see: stackoverflow.com/tour (takes less then 1 min and show's how it all works with voting and so on) Commented Nov 20, 2014 at 3:09
  • 1
    You need to understand also, the difference in using double quotes vs single quotes. Double quotes PHP will try to parse variables, single it will not. Commented Nov 20, 2014 at 16:22

2 Answers 2

2

This should work for you:

echo "<br /><a href='" . base_url() . "home/do_logout'>Logout Fool!</a>";
Sign up to request clarification or add additional context in comments.

Comments

1

Using mixed mode processing looks cleaner some of the time - and easier to maintain. Close and reopen your php tags when you want to switch to just html

<br>
<a href="<?php echo base_url(); ?>/do_logout">Logout Fool!</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.