Jump to content

Recommended Posts

Posted

deixo aqui uma ajuda à malta.

<?php 
		if( isset( $HTTP_GET_VARS['componente'] ) )
		{ 
			$componente = $HTTP_GET_VARS['componente'];
			$file2open = $componente.".php";
			if (!file_exists( addslashes($file2open) ))
				{
					include("missing.php");
				}
				else
				{
					include( $file2open ); 
				}

		}
		else   //não há parametros
		{
			include("welcome.php");
		}
	?>

Perguntam vocês o k é?

um simples script que permite que façam um include instantaneo dentro de por exemplo um ficheiro chamado index.php

para o usarem basta fazer um link deste tipo http://xpto.xpto/index.php?componente=página.que.quero.abrir.sem.o.dot.php

ver http://aparicio.pt.to

aka Aparicio

Posted

Eu não costumo usar o $HTTP_GET_VARS['componente']

uso o simples $_GET['componente'] que tem o mesmo efeito...

Não percebi o uso do addslashes, para que efeito é usado? Se fizeres só

if (!file_exists($file2open) )

não dá o mesmo?

Cumps,

Pedantilva

Posted

$HTTP_GET_VARS era usado em versões antigas do PHP

foi substituido pelo $_GET no entanto continua a existir, mas pode vir a ser descontinuado em versões posteriores

por isso convem usar $_GET

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.