[Techtalk] PHP to open a web page?

Teri Solow tsolow at terisolow.com
Sat Nov 13 02:33:42 EST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Megan Golding imparted (2004-11-12 @ 14:58:58 +0000):
> I must be thinking about this problem wrong because I can't find anything on how to do this one thing with PHP. Here's what I want to do, in pseudo code:
> 
> if (some_variable == some_value)
>   pull up some web page
> else
>   pull up some other web page
> 
> This is being written in PHP (on Apache, under Linux). What the heck is this function I'm looking for?

I don't think I really understand your question, but if you are trying
to do what I _think_ you are, there are serveral ways of doing it, one
of which is:

<?php

	function webpage1() {
		echo <<EOF
<html>
	<head>
		<title>page1</title>
	</head>
	<body>
		stuff
	</body>
</html>
EOF;
	}

	function webpage2() {
		echo <<EOF
<html>
	<head>
		<title>page2</title>
	</head>
	<body>
		stuff
	</body>
</html>
EOF;
	}

	$some_variable = $_GET['some_variable'];
	if ($some_variable === "one") {
		webpage1();
	}
	else if ($some_variable === "two") {
		webpage2();
	}
	else {
		print "Invalid variable: $some_variable\n";
	}
	
?>

This would print out the HTML contained in functions webpage1 or
webpage2 depending on whether the page is called as
'http://example.com/example.php?some_variable=one' or
'http://example.com/example.php?some_variable=two', respectedly.

There are lots of other ways to do similar things, including simply
including other php files instead of putting the webpage contents into
functions and print statements.

- -- 
(n_ 	Teri Solow
//\ 	http://terisolow.com
V_/_ 	

If the aborigine drafted an IQ test, all of Western civilization would
presumably flunk it.
		-- Stanley Garn


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBlNfWCRjPPiFbVe8RAqgHAKDki5Al96gRSfp7XpR81IepOg/isQCg54xa
JLgJmUZ8ClB0dDRMGwYGgso=
=BQ1c
-----END PGP SIGNATURE-----


More information about the Techtalk mailing list