Writing Java with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
freewill09
Forum Newbie
Posts: 5
Joined: Tue Sep 08, 2009 5:00 pm

Writing Java with PHP

Post by freewill09 »

I want to feed a php variable into a javascript code.

<?php
echo "<script type=\"text/javascript'>;\n";
echo "var so = new SWFObject(\"../../../../playerMultipleMenuPackage/;');\n";
echo $_GET['$products_id'];
echo "\"/playerMultipleList.swf\", \"mymovie\", \"295\", "\200\", \"7\", \"#FFFFFF\");\n";
echo "so.addVariable(\"autoPlay\",\"no\");\n"
echo "so.addVariable(\"playlistPath\",\"playlist.xml\");\n";
echo "so.write(\"flashPlayer\");\n";
echo "</script>;\n";
?>

What is incorrect
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Writing Java with PHP

Post by jayshields »

For a start there are lots of mismatched quote marks.
freewill09
Forum Newbie
Posts: 5
Joined: Tue Sep 08, 2009 5:00 pm

Re: Writing Java with PHP

Post by freewill09 »

I want the php to write this code:

<script type="text/javascript">
var so = new SWFObject("../../../../playerMultipleMenuPackage/php variable/playerMultipleList.swf", "mymovie", "295", "200", "7", "#FFFFFF");
so.addVariable("autoPlay","no")
so.addVariable("playlistPath","../../../../playerMultipleMenuPackage/playlist.xml")
so.write("flashPlayer");
</script>
ell0bo
Forum Commoner
Posts: 79
Joined: Wed Aug 13, 2008 4:15 pm

Re: Writing Java with PHP

Post by ell0bo »

use a heredoc to clean that mess up my friend...
$js = <<<JS
<script type="text/javascript">
var so = new SWFObject("../../../../playerMultipleMenuPackage/php variable/playerMultipleList.swf", "mymovie", "295", "200", "7", "#FFFFFF");
so.addVariable("autoPlay","no")
so.addVariable("playlistPath","../../../../playerMultipleMenuPackage/playlist.xml")
so.write("flashPlayer");
</script>
JS;

echo $js;

Anything you need dynamic just replace with a variable...
freewill09
Forum Newbie
Posts: 5
Joined: Tue Sep 08, 2009 5:00 pm

Re: Writing Java with PHP

Post by freewill09 »

Thanks jayshields and ell0bo

did exactly what I needed to do
Post Reply