To keep the HTML text in the php variable, you need to add a slash for the quotes, but forgot the function for converting from HTML to PHP, you just need to completely place the HTML page into a PHP variable. Thank.

  • five
    Another one who thinks that girls on the Internet help faster :) $ php = <<< HEREDOC HTML page HEREDOC; $ php = 'I have mod more "" "'; // but this way you don’t need to screen quotes, but you need to screen apostrophes. Better yet, read something about the basics of the language. - ReinRaus
  • @ReinRaus is the same :) - zenith

5 answers 5

In occasion of quotes read . In general, here.

  • Do you really think that people are reading here? =) - Node_pro
  • And God knows them :) In any case, there are a couple of convolutions of individuals. - Vyacheslav Kirichenko

htmlspecialchars - like the function you need .

    $a = <<<HERE ТУТ Html документ here; 

    Note the space after <<<HERE or before here; should not be, otherwise there will be an error. Addition
    In order to screen characters in a variable, you can use the mysql_escape_string function. Example of use:

      $a = <<<HERE ТУТ Html документ here; $a = mysql_escape_string($a); 

    ReinRaus, =))

    • but there was some sort of translation function, specifically for storing a database ... or who accidentally remembers? - Sexy Girl
    • Do you want to store html code in a database? - Node_pro
    • I did not seem to ask to ask questions, I myself ask. Please help out somebody - Sexy Girl
    • You are an interesting person, how can I help you if you didn’t specify what you need ... And by the way, your question has already been answered (to the first question) - Node_pro
    • one
      addslashes() here is the function go to you? In general, to successfully add to the database there is a function: mysql_escape_string() - Node_pro

    We write our html to a file, for example superCoolPage.html , let's say we save it to the static folder in the root of the site, then we read its contents:

     $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/static/superCoolPage.html'); // profit 

    @johniek_comp - limit comments. I'm not driving here, you will understand “undersized”. Smile - drove into hashcode search DOCUMENT_ROOT - your fourth question
    • one
      $ _SERVER ['DOCUMENT_ROOT'] is not cross-platform, smoke dir IMHO - johniek_comp
    • You need to be an asshole to use $ _SERVER ['DOCUMENT_ROOT'] - VasyOk
    • 2
      @VasyOk - I understand you, you are their those who, after reading some info from a pseudo-authoritative source, sacredly take it on faith and prove with foam at the mouth "once right opinion." “if I’m not mistaken because of the slash, everything ends up at the end” - if I’m not mistaken - it's hard to call it an example, everything always worked for me both under Windows and Nix, respectively, the problem is hand curves, not DOCUMENT_ROOT. I am absolutely not ashamed of this code, could you demonstrate the master class and show how would you rewrite this code? ###### ... after you refine / edit projects ... - mutually - Zowie
    • one
      I support. I want to see a master class. - ReinRaus
    • one
      @VasyOk. Using the file_get_contents () function is most preferable if you need to retrieve the contents of the entire file, since the function uses the memory mapping technique to improve performance if it is supported by your operating system. - ReinRaus
      $page = file_get_contents('http://ссылка.com'); 

    Your page between quotation marks will be in the form of HTML text (code) in the $ page variable.