Include with parameters

Asked

Viewed 54 times

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'); he returns one echo with the error sampled:

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

That would be possible?

1 answer

1


Yes it is possible! If you really want to accomplish include passing track parameter GET, should pass to Full file URL 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 so:

php.

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

info.php

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.