PDA

View Full Version : PHP


pete
15-10-2005, 04:21 PM
Although not a php newbie - theres still lots of things i havent got around to learning yet .



I've seen on other websites simple stuff like 'this page took 0.40 seconds to generate' etc .



A google search and some playing around would of course teach me how to do that sort of thing blah blah blah .



But apart from most php tutorials being bloody awful to look at and use they lack the option of asking a question .



Any users on here know their way around php ? .

Carl Shepherdson
16-10-2005, 02:28 PM
Although not a php newbie - theres still lots of things i havent got around to learning yet .



I've seen on other websites simple stuff like 'this page took 0.40 seconds to generate' etc .



A google search and some playing around would of course teach me how to do that sort of thing blah blah blah .



But apart from most php tutorials being bloody awful to look at and use they lack the option of asking a question .



Any users on here know their way around php ? .



Can't say I do style_emoticons/<#EMO_DIR#>/sad.gif



I know Matt know's a fair bit of PHP, ASP. He should be able to offer some help style_emoticons/<#EMO_DIR#>/biggrin.gif

pete
16-10-2005, 07:38 PM
php is quite easy once you manage to get started with it .



Like html it tends to be the same bits of code reused over and over again and rewitten to suit .



Its the doing something you havent done before thats annoying because to need to (a) find a suitable command to do the job and (style_emoticons/<#EMO_DIR#>/cool.gif learn how to use it .



Not a ideal situation if your a bit lazy like myself .



<?php

print "CS NEW MEDIA";

?>



or



<?php

$carl="CS NEW MEDIA";

print $carl;

?>



Stunning eh! :-)



But seriously - php is great for headers and nav menus as you can use something called 'include' files and use the same piece of code over and over again .



ftp into that film website i'm working on and download it if your the slightest bit interested as a practical example of include files is probably much better than a tutorial about them .

Carl Shepherdson
17-10-2005, 10:17 PM
php is quite easy once you manage to get started with it .



Like html it tends to be the same bits of code reused over and over again and rewitten to suit .



Its the doing something you havent done before thats annoying because to need to (a) find a suitable command to do the job and (style_emoticons/<#EMO_DIR#>/cool.gif learn how to use it .



Not a ideal situation if your a bit lazy like myself .



<?php

print "CS NEW MEDIA";

?>



or



<?php

$carl="CS NEW MEDIA";

print $carl;

?>



Stunning eh! :-)



But seriously - php is great for headers and nav menus as you can use something called 'include' files and use the same piece of code over and over again .



ftp into that film website i'm working on and download it if your the slightest bit interested as a practical example of include files is probably much better than a tutorial about them .



Very clever! I must find some time to learn all these technologies style_emoticons/<#EMO_DIR#>/biggrin.gif

Matt
19-10-2005, 04:47 PM
This script basically times how long PHP takes to parse and execute a script

<?php



// start the timer

$timeparts = explode(' ',microtime());

$starttime = $timeparts[1].substr($timeparts[0],1);



// Do something



// get the current execution time

// can be called more than once

$timeparts = explode(' ',microtime());

$endtime = $timeparts[1].substr($timeparts[0],1);

$time = bcsub($endtime,$starttime,6);



?>



Breaking it down, this script is fairly easy, it contains two main steps, the first of which catches the current time set by your PC. The second catches the current time of your PC again and then takes the the first time away from the second time.



Looking more closely you can see that, for acurcy, because sometimes PHP can do things in less than one second, we play with the microtime function. I expect you know a bit about PC's, they do things a lot faster than us humans, this is because they use a clock in the computer that ticks a lot faster than our clocks. Microtime basically uses the computer time rather than the human time to work out how long it has taken for the script to run. Microtimes can be turned into human times such as 0.358728 seconds.



The above script should sort you out with timing your scripts, when playing around with PHP as a beginner you should really try to make things faster rather than neater. This will help you create better PHP scripts when you come to making something useful such as:

http://matthewbonner.homeip.net/su-server_status (take a look with Firefox)



If you want to know more about PHP, there is an unbeatable guide that you can provide feedback to, although you are not supposed to ask questions, I am sure your question will be answered after a couple of weeks:

http://www.hudzilla.org/phpbook/



To use the timer usefully you could do something like this:

<?php



// start the timer

$timeparts = explode(' ',microtime());

$starttime = $timeparts[1].substr($timeparts[0],1);



// Do something



// get the current execution time

// can be called more than once

$timeparts = explode(' ',microtime());

$endtime = $timeparts[1].substr($timeparts[0],1);

$time = bcsub($endtime,$starttime,6);



// echo is faster than print

echo $time;



// get the current execution time

// can be called more than once

$timeparts = explode(' ',microtime());

$endtime = $timeparts[1].substr($timeparts[0],1);

$time = bcsub($endtime,$starttime,6);



/* echo can also be called just like a function, this is because it is really a function */

echo ($time);



?>

pete
20-10-2005, 02:28 AM
[b]

If you want to know more about PHP, there is an unbeatable guide that you can provide feedback to, although you are not supposed to ask questions, I am sure your question will be answered after a couple of weeks:

http://www.hudzilla.org/phpbook/





That looks quite good from a quick glance - with any luck will have a good read at the weekend .

Matt
25-10-2005, 02:16 AM
There are a lot of changes to PHP 5 which makes the language more flexible and easier to program but only to somebody with experience with PHP 4, I recommend you learn how to program in PHP 4 before taking a look at PHP 5.

Carl Shepherdson
25-10-2005, 06:26 PM
We have PHP 4 & 5 installed on the server. We still use 4 by default for compatibility reasons, but if you want to use 5 you can just change it HELM by selecting HELM extensions > Advanced Domain Options > Select the domain you want to change > PHP Version > and select PHP5! 8)



Of course if you do change it my affect some of your applications which use 4 style_emoticons/<#EMO_DIR#>/smile.gif

Matt
27-10-2005, 02:03 PM
Of course if you do change it my affect some of your applications which use 4 style_emoticons/<#EMO_DIR#>/smile.gifYep, caused by poor programming, all the recommended practises still work with PHP 5 but all these free scripts such as phpBB are getting old now and use old methods like Windows but if this was not the case we would not have all these fantasic things to play with.

Nick Irvine
27-01-2006, 06:10 PM
I'm pretty good with php... if i say so myself.

Send a message to the helpdesk if you need urgent help, or even not so urgent! style_emoticons/<#EMO_DIR#>/smile.gif

A good site for tutorials:

http://www.phpfreaks.com/