Php in .js file


















It's been nearly 6 years, and this still gets upvoted occasionally. This is absolutely terrible advice. You should strongly consider why you're needing to do this, and consider an alternative structure. If these variables can change over time, perhaps make an AJAX endpoint which represents what you need.

Sure it's not great architecturally, but for beginners needing a quick and dirty method it works fine. Now the php pages get downloaded on access — JVE Can you explain how this "will allow the client to potentially see the contents of your PHP file" — mvndaai. NikiC NikiC Scot Bernard Scot Bernard 5 5 silver badges 5 5 bronze badges.

Josiah Josiah 4, 1 1 gold badge 18 18 silver badges 19 19 bronze badges. Instead of messing with generic php-handlers do a 1-file exception using a rewrite: Rename the. Cristian Sanchez Cristian Sanchez Using Uniter along with php. Paul Dixon Paul Dixon k 49 49 gold badges silver badges bronze badges. The question is can I call a php function inside of an included. I just don't want to have a bunch of PHP files with code in them sitting around.

I'd like to incorporate the code in PHP functions in a. You could have all your functions in a single file then create a. This API could be in a single file or multiple, it depends on what you want. Once you use AJAX to call the. There is no difference. It sounds like that is what is mixing you up. You can include any other script in the execution that you need to.

Also you can include arguments via post or get to specify what files you need to include in the. Show 1 more comment. For example: page. Sarfraz Sarfraz k 70 70 gold badges silver badges bronze badges.

PHP has to be parsed on the server. JavaScript is working in the client's browser. Natascha Natascha 41 1 1 bronze badge. William Ausling William Ausling 43 6 6 bronze badges. That header is not needed. Wrong, you need this header, if you create a service workers 'sw. Pablo Santa Cruz Pablo Santa Cruz k 30 30 gold badges silver badges bronze badges. A "hello world" program doing what exactly? Basically what I think he's saying is if the above was code snippet was in a.

It should be noted that it might not necessarily the way you expect it to, depending on what you expect. Oli Oli k 62 62 gold badges silver badges bronze badges. A small demo may help you: In abc. Phate01 2, 1 1 gold badge 27 27 silver badges 49 49 bronze badges. Zhang Evan Zhang Evan 11 1 1 bronze badge. Contact us now for a free consultation. What can we help you with? WordPress Hosting. WordPress Updates. Website Portfolio. Website Design. What I need to do is the other way around. Is it possible?

How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to write the php code in js file Ask Question.

Asked 11 years, 3 months ago.



0コメント

  • 1000 / 1000