Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

correct javascript + php syntax, easy

Hi,
I've got a PHP file, and I want to create an include path using a php variable. Right now I have this:

<script type="text/javascript" src="$mainframe->getCfg('live_site')/$tiny_url/$tiny_file"></script>

It almost works, just the part with:
 
    $mainframe->getCfg('live_site')

messes up. When the PHP page is generated, it comes out like:

<script type="text/javascript" src="('live_site')/some_path/the_file_name"></script>

I must be missing some quotes or something? I'm a PHP/js novice,

Thanks

ASKER CERTIFIED SOLUTION
Avatar of BraveBrain
BraveBrain
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ncoo
ncoo

The other is:

<?php

echo '<script type="text/javascript" src="'.$mainframe->getCfg('live_site').'/'.$tiny_url.'/'.$tiny_file.'"></script>';

?>
Avatar of DJ_AM_Juicebox

ASKER

Hi guys,

It doesn't seem to be working - my file is indeed a php file, the first line is:

        <? php

and the php tag is not closed till the end of the file. Now there is a bunch of php code above my line working fine, but then a strange 'return <<<EOD' statement. Kind of looks like:

<?php

     .... some ok php stuff ...

      return <<<EOD  

       <!--   An html comment parsed correctly in the generated page!!!   -->

       echo "hello"        // a basic echo call which fails!!!
?>

I'm not sure what the return <<<EOD statement does, or how the html comment is getting parsed correctly when it is still within the php braces. Anyone have an idea?

Thanks
actually if i put the echo statements before that

      return <<<EOD

line, everything works as expected. What is it!

With out seeing all the code it's hard to tell if the return is php or javascript.

Return returns the product of a function.

function functionname() {
value = 1 + 1;
retrun value;
}

return <<<EOD

looks like bad code maybe it should be:

return '<<<EOD';

echo "hello"       // a basic echo call which fails!!!

it should be

echo "hello"; //it needs the ;