Here doc issue in PHP

Discussion in 'PHP' started by misslilbit02, Aug 21, 2007.

  1. #1
    Hi,

    I'm trying to do a here doc. I want didn't pages to appear based on the user selection. So I have the heredoc in different functions. The issue I'm having is somewhere down the line it does not read my php code any longer.

    So when I write <?php echo $variablename; ?> it won't interpret it. When you look at the source in the browser it writes the php code out and the php code shouldn't been seen in the browser.

    Is it a problem with the quotes?

    I'll include a little bit of code so you can see what I'm doing because it's way too much code to put here.

    <?php
    
    if(isset($_GET['id']) && !$_GET['id'] = "")
    {
    	
    	load_swf();
    }
    	else
    	{
    		load_thumbnails();
    	}
    
    function load_thumbnails()
    {
    
    $thispage = $_SERVER['PHP_SELF'];
    
    	$form_page = <<<EOFORMPAGE
    	<HTML>
    	<HEAD>
    	<title>Online Library</title>
    <script type="text/JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    <style type="text/css">
    <!--
    .style1 {font-family: Geneva, Arial, Helvetica, sans-serif}
    .style2 {font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; }
    body {
    	background-color: #FFFFFF;
    	margin-top: 0px;
    	margin-left: 0px;
    }
    a:link {
    	color: 666666;
    }
    a:visited {
    	color: 666666;
    }
    a:hover {
    	color: cccccc;
    }
    a:active {
    	color: cccccc;
    }
    -->
    </style>
    
    <script language="JavaScript">
    
    <!-- Hide the script from old browsers --
      function surfto(form) 
    {       
            var myindex=form.dest.selectedIndex
            if (myindex!=0){
            window.open(form.dest.options[myindex].value, "_self")};
    }
    // --End Hiding Here -->
    
    </script>
    
    </head>
    <body onload="MM_preloadImages('images/accounting2.jpg','images/alternative medicine2.jpg','images/applied management2.jpg','images/AQUATIC ENGINEERING2.jpg','images/aviation management2.jpg','images/aviation science2.jpg','images/baking and pastry arts2.jpg','images/business administration2.jpg','images/computer animation design and drafting2.jpg','images/COMPUTER GRAPHICS AND DESIGN2.jpg','images/computer networking and security mgmt2.jpg','images/computer networking with emerging technologies2.jpg','images/computer programming2.jpg','images/construction management2.jpg','images/criminal justice2.jpg','images/crrime scene technology2.jpg','images/culinary arts2.jpg','images/diagnostic medical sonography2.jpg','images/elementary education2.jpg','images/fashion design and merchandising2.jpg','images/fire science2.jpg','images/health services2.jpg','images/health services administration2.jpg','images/homeland security2.jpg','images/massage therapy2.jpg','images/medical assisting2.jpg','images/medical billing and coding2.jpg','images/medical laboratory technology2.jpg','images/mgmt information systems2.jpg','images/NUCLEAR MEDICINE TECHNOLOGY2.jpg','images/physical therapy assistant2.jpg','images/pratical nurse2.jpg','images/professional aviation2.jpg','images/radiologic technology2.jpg','images/spa management2.jpg','images/sports medicine and fitness technology2.jpg','images/surgical technology2.jpg','images/video game design2.jpg','images/nursing2.jpg','images/occupational therapy assitant2.jpg','images/paralegal studies2.jpg','images/paramedical esthetician2.jpg','images/pharmacy technology2.jpg')">
    <table width="674" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="674" bgcolor="#999999">
    Code (markup):
    Thanks for any assistance you can give.
     
    misslilbit02, Aug 21, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Have a look at the Manual page.

    Don't use <?php ?> tags inside any kind of strings, neither heredoc.
     
    nico_swd, Aug 22, 2007 IP
  3. ssanders82

    ssanders82 Peon

    Messages:
    77
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why are you saving all that text to a variable anyway? Can you separate it out into another file and call "include" when you need it?
     
    ssanders82, Aug 23, 2007 IP