Use of parentheses with variables

Should
$output .= htmlspecialchars($author[‘name’], ENT_QUOTES, ‘UTF-8’) . “ (numjokes jokes)<br>”;
(which is on page 351 of the fifth edition of PHP & MYSQL: NOVICE TO NINJA) have results like:

Kevin Yank (3 jokes)
Jessica Graham (1 jokes)?

I’m not sure if these results are supposed to be like the results on page 352, which are like:

Kevin Yank 3
Jessica Graham 1.

The results below are different than the ones above, because the jokes below don’t have parentheses or the word “jokes”.

The results on p352 are the result of the query (displayed just above the results) NOT a result of the code you have posted.

Would the code I posted result in something like the results above the other results I posted? (I’d test it myself, but I’m still trying to figure out if I can and should use a Raspberry Pi.)

Yes, I think so, but there must be something else going on. You code has the word jokes on the end, but something must be parsing the numjokes to replace it with a number.

I think numjokes should be $numjokes.

2 Likes

Good catch. If intentional, I would be tempted to run the other way seeing syntax mixed like that.

1 Like

Yes, good catch. I misquoted the book.