Level 80
@laravel_is_right You can’t use JavaScript in PHP. PHP is executed on the server. JavaScript is executed in your browser. The PHP process has already finished before a single line of JavaScript is executed.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi there. Here is part of my code :
...
function minicart(courseId="")
{
$.ajax({
type: "GET",
datatype: "json",
url: "/cart/basket",
success:function(response)
{
<?php
$course = Course::where("id",***courseId)->get();
?>
...
I need to use courseId value in where part, but i don't know the right syntax about that. How should i write CourseId in my php part? Thanks.
Please or to participate in this conversation.