Include with parameters

1

How do I include another php file passing information with it, for example I aim to include a php that has a message system that creates a temporary html that error:

For example, I want to give include('info.php?page=sem-nome'); back a echo with the error sampled:

<?php 
    echo "<h2 style=\"color: red\">Página não encontrada: " . $_GET['page'] . "</h2>";
?>

Would that be possible?

    
asked by anonymous 22.08.2016 / 23:39

1 answer

1

Yes it is possible! If you really want to do include passing parameter via GET , you must pass the full URL of the file info.php .

Example:

include 'http://www.exemplo.com.br/info.php?page=sem nome';

If you do not want to use the full URL, you can do this:

file1.php

<?php
$page = 'sem nome';
include('info.php');

info.php

<?php
echo "<h2 style=\"color: red\">Página não encontrada: " . $page . "</h2>";
    
22.08.2016 / 23:42