通过按钮onclick [关闭]调用PHP变量

The goal is to call the variable $url when the button is clicked. With this current bit of code, when the button is clicked nothing happens and the error says unexpected token.

     <?php
        $url = "edit_beginningcakephp.php?title=$title&author=$author&isbn=$isbn
                &year=$year&pages=$pages&price=$price";
            >?

  <input type="button" value="Edit Book" onclick="window.location.href='<?= $url ?>'">

I suppose you're not correctly encoding the content of the variables (known as XSS)

You need to urlencode the content of your variables. Also, & needs to be entered as an HTML entity &amp;.

Try:

$url = 'edit_beginningcakephp.php?title='.urlencode($title).'&amp;author='.urlencode($author).'&amp;isbn='.urlencode($isbn).'&amp;year='.urlencode($year).'&amp;pages='.urlencode($pages).'&amp;price='.urlencode($price);

PS: >?should be ?> and make sure the URL doesn't contain any newlines.

" >? " That looks like it might be a problem, definitely throws a syntax error on my local :)

While MrTux's answer is very good and his advice should surely be followed, the actual problem with your code is the return in the URL. URLS can't contain returns!
Solution: delete the return. And the spaces. And follow MrTux's advice.