Jump to content

something wrong with getting a value from adres bar


clankill3r

Recommended Posts

i have this in the adressbar:

truncate.php?msg=historer_words

 

but on screen i get,

why

instead of the expected:

Truncated <? $_GET['mgs'] ?>

 

Does someone sees what's wrong in my script?

 

<?php 

?>

<html>
<head>
	<title>Historer : Truncate</title>
</head>

<body>

	<? 
	if(isset($_GET['mgs'])) {
		?><div id="message">Truncated <? $_GET['mgs'] ?></div> <?	
	} else {
		?><div id="message">why </div> <?	
	}		
	?>

	<div id="container">
		<a href="inc/php/utils/truncate.php?table=historer_words">Truncate words</a>
	</div>
</body>
</html>

Note that you spelled "address" wrong in your thread title.  Note also that you spelled "msg" wrong in your code.

 

Programming takes an enormous amount of precision.  if you're off by one letter, like you are here, nothing will work.  Make sure you are more careful.

php.net: Escaping from HTML

 

while some people find short tags and ASP style tags convenient, they are less portable, and generally not recommended.

 

Also note that if you are embedding PHP within XML or XHTML you will need to use the <?php ?> tags to remain compliant with standards.

 

Short tags (example three) are only available when they are enabled via the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.

 

Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.

 

however

Starting with PHP 5.4, short echo tag <?= is always recognized and valid, regardless of the short_open_tag setting.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.