jamil athar
jamil athar

Reputation: 101

php quotation mark is not working

I am facing some problem in PHP code. It is a basic question but I don't know the answer. The code is here:

echo '<a href="profile.php?act=show&id=<?=$_SESSION['id']?>&line=true" class="myac">My Data</a>';

How to use the quotation mark in the id? Please help me.

Upvotes: 1

Views: 41

Answers (2)

Vivek Singh
Vivek Singh

Reputation: 2447

apart from the above mentioned way by @praveen u can use it like below also if u don't want to put the anchor tag inside php

 <a href="profile.php?act=show&id=<?php echo $_SESSION['id']?>&line=true" class="myac">My Data</a>

Upvotes: 0

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

That's wrong. Already you are using echo. So concatenate the value this way:

<?php
  echo '<a href="profile.php?act=show&id=' . $_SESSION['id'] . '&line=true" class="myac">My Data</a>';
  //-------------------------------------^^^^^^^^^^

And please refrain from using short tags (<? ?>), use full tags: <?php ?>.

Upvotes: 5

Related Questions