View Full Version : PHP variable in JavaScript

Jon Weir
03-30-2006, 12:44 PM

Anyone any idea why the JavaScript code below displays the variable I explicitly declared but not the variable defined by the result of the XSL transform? i.e. when you change $foo to $earth there is no output. (my xsl fragment is at the bottom of this message).


PHP Code:

//XMLXSL Transformation class

$mm_xsl = new MM_XSLTransform();
$earth = $mm_xsl->Transform();
$foo = 'bar';

echo $earth;
echo $foo;

var a = "<?php echo $foo;?>";


XSL fragment:

<?xml version="1.0" encoding="iso-8859-1"?><!-- DWXMLSource="http://feeds.feedburner.com/usgs/eqs1day-M25" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "*">
<!ENTITY copy "">
<!ENTITY reg "">
<!ENTITY trade "">
<!ENTITY mdash "">
<!ENTITY ldquo "">
<!ENTITY rdquo "">
<!ENTITY pound "">
<!ENTITY yen "">
<!ENTITY euro "">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:atom10="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="ItemsPerPage" select="20"/>
<xsl:template match="/">

<xsl:for-each select="rss/channel/item">
<xsl:sort select="title" order="descending"/>
<xsl:if test="position() &lt; 2">
<xsl:value-of select="title"/>