html - how to use single and double quotes with brackets in php?

664

i have a problem using with single and double quotes with brackets in php

$nestedData[] = '<a href="JavaScript:newPopup('loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>';
579

Answer

Solution:

You need to escape the quotes or concat the strings:

$nestedData[] = '<a href="JavaScript:newPopup('loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>';
                                              ^ here your string ends

You can change to:

$nestedData[] = '<a href="JavaScript:newPopup(\'loghistory.php?logid='.$row['user_id'].'\')"> History('.$countqry.')</a>';

Or another option:

$nestedData[] = '<a href="JavaScript:newPopup('. "'loghistory.php?logid='" .$row['user_id']. "'" . ')"> History('. $countqry .')</a>';
929

Answer

Solution:

You can escape single and double quotes with \ Like this:

'You\'re'
913

Answer

Solution:

$nestedData[] = '<a href="JavaScript:newPopup('loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>';

try the below code:

<a href="JavaScript:newPopup("loghistory.php?logid='.$row['user_id'].'')"> History('.$countqry.')</a>
985

Answer

Solution:

If you wish to output a single tick from within a litteral string then you will need to escape that single quote:

$a = 'Graeme\'s example';
echo $a;

Will output:

Graeme's example

722

Answer

Solution:

$nestedData[] = "<a href=\"JavaScript:newPopup('loghistory.php?logid='".$row['user_id']."')"."\"> History('".$countqry."')</a>";

Escape the quotes with \

this should do the trick

576

Answer

Solution:

$nestedData[] = '<a href="JavaScript:newPopup('".loghistory.php?logid='".$row['user_id']."'."')"> History("'.$countqry.'")</a>';

People are also looking for solutions to the problem: php - Laravel 5 - Moved User model to App/Models causing autoload issues

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.