Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP question

Options
  • 25-11-2007 3:20pm
    #1
    Registered Users 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 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