simple php problem insert string in html

Discussion in 'PHP' started by abdo629, Sep 21, 2011.

  1. #1
    i am new with php

    i think that my problem is simple

    http://www.facebook.com/share.php?u=PERMALINK&t=TITLE

    $info[0] in the title

    $_SERVER['HTTP_REFERER'] in the u


    i want your help


    my code


    
    
    <?php
    //  Get Site Title
    function getSiteTitle(){
    $RefURL = (is_null($_SERVER['HTTP_REFERER'])) ? 'Un know' : $_SERVER['HTTP_REFERER'];
      if($RefURL != 'Un know'){
       $con = file_get_contents($RefURL) or die (" can't open URL referer ");
       $pattern = "/<title>(.+)<\/title>/i";
       preg_match($pattern,$con,$match);
       $result = array($match[1],$RefURL);
       return $result;
      }
      else{
       return false;
      }
    }
    
    $info = getSiteTitle();
    
    ?>
    
    
    
    <?php
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
     <title>'.$info[0].'</title>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <meta name="robots" content="noodp,noydir" />
    <link type="text/css" rel="stylesheet" href="/wp-content/plugins/hunk-external-links/redirect.css" />
    </head>
    <body class="UIFramedPage">
    <table style="height: 100%;" id="page_table" class="page_table unknown_page" cellpadding="0" cellspacing="0">
    <tbody>
    
    <tr>
    	<td class="content_cell" id="content_cell">
    		<div class="content_cell_inner_shadow">&nbsp;</div>
    		<iframe id="content_iframe" class="content_iframe" name="content_iframe" src="'.$_GET['hr'].'" scrolling="auto" frameborder="0"></iframe>
    	</td>
    </tr>
    <tr>
    	<td class="header_cell" id="header_cell">
    	<div class="url_bar unknown_url">
    	<a title="Remove frame and go to this web address." class="url_fragment" href="'.$_SERVER['HTTP_REFERER'].'">'.$info[0].'</a> العودة الى 
    
    [COLOR="#FF0000"][SIZE=5]	<a  href="http://www.facebook.com/share.php?u=PERMALINK&amp;t=TITLE">share</a> [/SIZE][/COLOR]
    
    
    
    
    	</div>
    	</td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>';
    ?>
    
    
    
    Code (markup):
     
    abdo629, Sep 21, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Removing brackets after $info could be helpful.
     
    mastermunj, Sep 21, 2011 IP
  3. jevchance

    jevchance Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Dunno if this will help, but you could use a heredoc instead of trying to put that big string in single quotes. That would help you avoid any syntax errors being caused by quotes. Here's an example:

    $var = array("MEMEME");

    ECHO<<<EOF
    Hello, I am $var[0]
    EOF;
     
    jevchance, Sep 21, 2011 IP
  4. MarPlo

    MarPlo Member

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    48
    #4
    Hy,
    Try replace (is_null($_SERVER['HTTP_REFERER'])) ? 'Un know' : $_SERVER['HTTP_REFERER']; with a valid url and see what you get with var_dump($info). I tested the code and it works fine.
     
    MarPlo, Sep 21, 2011 IP
  5. abdo629

    abdo629 Greenhorn

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    thanks all of you for your help
     
    abdo629, Jan 6, 2012 IP