Practicing

Soldato
Joined
2 May 2004
Posts
19,950
Hi,

Any ideas what I can do to practice some PHP? I want to learn more ;)
Today I did this today, but it was too easy:

Code:
<?

function tpl($d, $o){
  DEFINE($d, $o);
}

$layout[1] = '<table width="100%" border="1"><tr><td><b>items</b></td><td><b>_SERVER code</b></td></tr>';
$layout[2] = '<tr>';
$layout[3] = '<td>';
$layout[4] = '</td>';
$layout[5] = '</tr>';
$layout[6] = '</table>';

$l = $layout;

tpl('l1', $l[1]);
tpl('l2', $l[2]);
tpl('l3', $l[3]);
tpl('l4', $l[4]);
tpl('l5', $l[5]);
tpl('l6', $l[6]);

$uAddr = $_SERVER['REMOTE_ADDR'];
$uAgent = $_SERVER['HTTP_USER_AGENT'];
$uHost = $_SERVER['HTTP_HOST'];
$uDocRoot  = $_SERVER['DOCUMENT_ROOT'];
$sName = $_SERVER['SERVER_NAME'];
$sSoftware = $_SERVER['SERVER_SOFTWARE'];
$sSig = $_SERVER['SERVER_SIGNATURE'];
$rURI = $_SERVER['REQUEST_URI'];

echo l1;

echo l2;
echo l3;
      echo $uAgent;
echo l4;
echo l3;
      echo 'HTTP_USER_AGENT';
echo l4;
echo l5;


echo l2;
echo l3;
  echo $uAddr;
echo l4;
echo l3;
  echo 'REMOTE_ADDR';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $uHost;
echo l4;
echo l3;
  echo 'HTTP_HOST';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $uDocRoot;
echo l4;
echo l3;
  echo 'DOCUMENT_ROOT';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $sName;
echo l4;
echo l3;
  echo 'SERVER_NAME';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $sSoftware;
echo l4;
echo l3;
  echo 'SERVER_SOFTWARE';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $sSig;
echo l4;
echo l3;
  echo 'SERVER_SIGNATURE';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $rURI;
echo l4;
echo l3;
  echo 'REQUEST_URI';
echo l4;
echo l5;

echo l2;
echo l3;
  echo $uDocRoot;
  echo $rURI;
echo l4;
echo l3;
  echo 'DOCUMENT_ROOT & REQUEST_URI';
echo l4;
echo l5;


echo l4;

?>

Unecessarily (sp?) complicated, but it was to practice. I did it all off the top of my heae, no manuals or anything, but as I said it was too easy and I didn't learn anything from it >.<

So, any other ideas of what I can write to practice / learn more ?

Craig.
 
SamHandwich said:
Not to sound patronising, but I'd reccomend at least having a look at the manual at http://uk.php.net. I don't think I've ever seen such a long winded way of going about something. Maybe to practice you should try and cut that code down to, ooh I dunno, I reckon it could be done in 10 lines or less.

I made it complicated on purpose, as I said to practice using functions, define etc.

I wouldn't normally use that code, that's just silly.
 
hendrix, not sure what you mean?

I thought maybe writing a forum might be a good idea, I'd start by doing the simple parts like new topic, reply to thread etc. And then I'd go onto the extras.
 
Ah, OK. Just wasn't sure what you meant by "Have a bash at Pool/Snooker Tournement or something like that."

I did start a message board a while ago, I got stuck on replies though, it wouldn't list all the replies to the thread for some reason. I'll probably start it again and see if I can do it this time :)

Craig.
 
Back
Top Bottom