T
T
toaster khabrovich2015-12-09 16:31:37
PHP
toaster khabrovich, 2015-12-09 16:31:37

How to assemble a new php script from strings and values ​​in a php script and save it to disk?

<?php


if(empty($_SERVER['PHP_AUTH_USER']))                 
  {	
  header('WWW-Authenticate: Basic realm="WWW-Authenticate"');   
  header ('HTTP/1.0 401 Unauthorized'); 
  exit();                                              
  }

$login = md5($_SERVER['PHP_AUTH_USER']);                    
$parol = md5($_SERVER['PHP_AUTH_PW']);



$html = <<<_END
<?php
if (md5($_SERVER['PHP_AUTH_USER'] != $login || md5($_SERVER['PHP_AUTH_PW']) != $parol)
{
header('WWW-Authenticate: Basic realm="WWW-Authenticate"');
header ('HTTP/1.0 401 Unauthorized'); 
exit(); 
}
?>
_END;

// далее создание файла.html из $html

?>

It is necessary that on one page another page is formed from the login and password received from the user, which is then saved to disk
. I can’t understand why <<<_END doesn’t work
.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Andrew, 2015-12-09
@studententer

<?php

$login='username';
$html = <<<_END
<?php
\$login='{$login}';
if (md5(\$_SERVER['PHP_AUTH_USER'] != \$login || md5(\$_SERVER['PHP_AUTH_PW']) != \$parol)
{
header('WWW-Authenticate: Basic realm="WWW-Authenticate"');
header ('HTTP/1.0 401 Unauthorized'); 
exit(); 
}
?>
_END;

?>

A
alex stephen, 2015-12-09
@berezuev

To insert a piece from another php file into a php file, it is enough to write:
And about <script language="php">
Every time you use this syntax, somewhere in the world a kitten is crying...

S
Stalker_RED, 2015-12-09
@Stalker_RED

Are you familiar with the include, require constructs ?

L
Lexans, 2015-12-10
@Lexans

I will answer the question asked by this user, but deleted by the moderators (What is it - the ideal CMS of the future?).
Boolive is truly the ideal CMS of the future.
versatile, advanced, comfortable, lightweight. suitable for the vast majority of tasks.
The bottom line is that everything on the site has objects (a set of data + logic) that make up two hierarchies: a parent-child and a prototype object (inheritance), and all this is controlled from the admin panel.
It's a very flexible system, I played it on LAN, fell in love with it already.
It is best to join this project, it is not possible for a beginner to write an ideal CMS from scratch. Boolive has been developing for several years
boolive.ru
habrahabr.ru/company/boolive/blog/211488

O
Optimus, 2015-12-09
Pyan @marrk2

Since when have we <script language="php">
and not
I'm even afraid to ask where you run it ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question