DEV Community

Cover image for How to use PHP within JavaScript on the Laravel framework.
Mahfuzur Rahman
Mahfuzur Rahman

Posted on

How to use PHP within JavaScript on the Laravel framework.

Hey Laravel Devs 📢
Do you know? You can use Laravel Blades

{{ }}
Enter fullscreen mode Exit fullscreen mode

in JS and use PHP variables in there.

Image description

Also, You Can Use Route In Ajax URL

Image description

But your JS must be in the Blade file inside the "script" tag.

Laravel #javascript

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more