Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

PHP question

  • 25-11-2007 02:20PM
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    hi
    im working on a php site at the moment and theres some thing i want to know if its possible in php

    at the moment i show some js script for google maps in my code kinda like thi s
    function showgmaps(){
    ?>
    <script type="text/javascript">
    
    function loadMap() 
    {
    	//<![CDATA[
    	
    	if (GBrowserIsCompatible()) {
    
    etc etc.....
            }
    }
    
    </script>
    
    <?
    
    }
    


    however what i need to do is to embed this function in a php variable (so i can sent it to the <head> tag

    at the moment i just go through all the js script and escape the 's - which is a BIG pain i the ass kind like this
    function showgmaps(){
    
    
    var $gmapscode='
    
    
    <script type="text/javascript">
    
    function loadMap() 
    {
    	//<![CDATA[
    	
    	if (GBrowserIsCompatible()) {
    
    etc etc.....
            }
    }
    
    </script>
    
    ';
    
    }
    



    is there any way to say


    
    var $gmapscode=everything between point 1 and point 2
    
    point 1
    ?>
    <script type="text/javascript">
    
    function loadMap() 
    {
    	//<![CDATA[
    	
    	if (GBrowserIsCompatible()) {
    
    etc etc.....
            }
    }
    
    </script>
    
    <?
    
    point 2
    


    follow me ?


Comments

  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    Are you just after this ???
    
    <?PHP
    
    function mapStuff()
    {
     
    echo <<<END
      function text in here ??? <br />
    END;
       
    }
    
    echo "before function call<br/ >";
    
    mapStuff();
    
    echo "after function call<br/ >";
    
    ?>
    
    

    or maybe I've not understood your question ?


  • Closed Accounts Posts: 975 ✭✭✭squibs


    You can use php to set variables serverside and use echo to generate the client side javascript with variables embedded, if that's what you mean. I have done this for yahoo maps and google maps.


Advertisement
Advertisement