Page 1 of 1

nl2br

Posted: Mon Dec 16, 2002 12:41 pm
by jamal
Hi Guys
Can anyone please rewrite this code snippet in
a professional way for me??

Code: Select all

<?php 

$server_software_get = getenv('SERVER_SOFTWARE');
echo "$server_software_get";?><br> 

<?php 
$server_software = explode(" ", $server_software_get);
echo "$server_software";?><br> 

<?php
$server_name = getenv('SERVER_NAME');
echo "$server_name";?><br> 

<?php
$gateway_interface = getenv('GATEWAY_INTERFACE');
echo "$gateway_interface"; ?><br> 

<?php

$server_protocol = getenv('SERVER_PROTOCOL');
print "$server_protocol"; ?><br> 
03

<?php 
$server_port = getenv('SERVER_PORT');
echo "$server_port"; ?><br> 

<?php 
$remote_port = $HTTP_SERVER_VARS['REMOTE_PORT']; 
print "$remote_port"; ?><br>

Posted: Mon Dec 16, 2002 2:38 pm
by Gen-ik
You should really pull your finger out and learn how to do this yourself.. asking people to re-write your code usually tends to <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> people off, especially when it's this simple.. but here it is anyway.. don't make a habbit of it.

Code: Select all

<?php

$server_software_get = getenv('SERVER_SOFTWARE'); 
$server_software = explode(" ", $server_software_get); 
$server_name = getenv('SERVER_NAME'); 
$gateway_interface = getenv('GATEWAY_INTERFACE'); 
$server_protocol = getenv('SERVER_PROTOCOL'); 
$server_port = getenv('SERVER_PORT'); 
$remote_port = $HTTP_SERVER_VARS['REMOTE_PORT'];  

echo ($server_software_get."<br>");
echo ($server_software."<br>"); // you do know this will echo an Array?
echo ($server_name."<br>");
echo ($gateway_interface."<br>");
echo ($server_protocol."<br>");
echo ($server_port."<br>");
echo ($remote_port."<br>");

?>

Posted: Mon Dec 16, 2002 3:29 pm
by jamal
Thanks Guys,
Yes I do. What are you trying to say??
Please tell me??

Posted: Mon Dec 16, 2002 3:34 pm
by jamal
Please do you have an easy way to do this???
Sending an HTTP headers to the browser before any HTML code is generated is giving me a lot bottleneck.
Any easy way???
Please tell me.

Posted: Mon Dec 16, 2002 3:39 pm
by puckeye
What are you saying jamal???

I don't understand your last 2 messages, they do not seem to be in any relaltions with Gen-ik's message...

Be specific.

Posted: Mon Dec 16, 2002 4:01 pm
by hob_goblin
you could even do this:

Code: Select all

echo getenv('SERVER_SOFTWARE').'<br>';
echo explode(" ", $server_software_get).'<br>';
echo getenv('SERVER_NAME').'<br>'; 
echo getenv('GATEWAY_INTERFACE').'<br>';
echo getenv('SERVER_PROTOCOL').'<br>';
echo getenv('SERVER_PORT').'<br>';
echo $HTTP_SERVER_VARS&#1111;'REMOTE_PORT'].'<br>';
Don't see why you need to do this...

The headers are automatically sent... you won't be needing to send any headers except maybe some location or cache if you're doing something complicated.

Posted: Mon Dec 16, 2002 4:51 pm
by Gen-ik
Please do you have an easy way to do this???
Sending an HTTP headers to the browser before any HTML code is generated is giving me a lot bottleneck.
Any easy way???
Please tell me.
If you are having 'header' problems with your script then just make sure you don't echo() anything before your HTML kicks in.

You can open PHP ( <?php ) setup variables then close PHP again ( ?> ) before your HTML. You can then do your HTML stuff and re-open your PHP, the variables will still be there.. they don't go anywhere unless you jump to another page or get rid of them.

You would do exactly the same thing if you were using Cookies as these need to be excuted before any page 'headers' are sent.


It might be worth checking out the PHP manuals and scritps on this site to get your head around a few ways of working with PHP.

Posted: Tue Dec 17, 2002 11:49 am
by JPlush76
:roll: