Re: [PHP] Including JS code that uses PHP
- Date: Wed, 6 Sep 2017 00:27:18 +0300
- From: Tolga <kacmaztolga@xxxxxxxxx>
- Subject: Re: [PHP] Including JS code that uses PHP
On 06-09-2017 00:10, Larry Martell wrote:
On Tue, Sep 5, 2017 at 5:03 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote:
On Tue, Sep 5, 2017 at 4:58 PM, Larry Martell <larry.martell@xxxxxxxxx>
var CLIENT_ID='<?php echo $CLIENT_ID; ?>'
If I put the JS code directly in a php file with:
Then at run time CLIENT_ID has the value I want. I want to use the
same JS code in many php files. But if I include the JS code like
Then that php code does not get run and CLIENT_ID has the literal
string '<?php echo $CLIENT_ID; ?>'
Is there a way I can reuse my JS file and still have embedded PHP in it?
It is because .js files are not parsed by PHP, not by default. An option
would be to just src="login.js.php" and then in that file output the client
id + js contenttype headers.
With that the PHP is being evaluated but it's resolving to an empty
string and not what $CLIENT_ID has in the PHP world.
how about like this?
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php