LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2005, 05:13 AM   #1
nickiv
LQ Newbie
 
Registered: Mar 2005
Location: south-Africa
Distribution: red hat 9.0
Posts: 12

Rep: Reputation: 0
Can I use PHP variables in javascript?


Hi

can I use php $variable in javascript functions?

like:

alert($phpvariable);
 
Old 06-07-2005, 05:41 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Sure, though I don't see what use it would be. Example:
Code:
<html><head><title>...</title>
<script ...><!--
alert('<?php echo($phpvariable); ?>');
--></script>
...
In the real world, provided you have some usage of this strange thing, you'd also have to take care of quotes in the value of your variable.

Yves.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
passing variables by reference in javascript djgerbavore Programming 2 06-07-2005 11:34 PM
Adding javascript variables to a PHP query Elijah Programming 7 11-07-2004 07:28 PM
PHP and JavaScript Gerardoj Programming 4 04-22-2004 02:02 PM
willing to pay $$$ PHP / Javascript multiple paged form; carrying over variables micro_sucks General 1 12-26-2003 09:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration