Blog by Andreas Glaser

Tag: PHP5

Portfolio - Ajax/PHP Navigation Guide for renowned Clinic

by Andreas Glaser on Nov.04, 2008, under Development, JavaScript, Joomla 1.x, My Portfolio, PHP, Various

Navigation Guide written in JavaScript/Ajax/PHP

My order was to develop a navigation guide which should help the visitors to discover the most important content of a website. This “NaviGuide” had to be realized as JavaScript/Ajax/CSS pop up on the fact that much users are using pop up blocker.

This NaviGuide runs since 24.July 2008 at www.stz-baden-baden.de implemented in the well known Content Managment System “Joomla”.

Leave a Comment :, , , , more...

PHP - count() vs. sizeOf()

by Andreas Glaser on Aug.19, 2008, under Computer, Development, PHP

I was wondering whether there is a performance difference between count() and sizeof().

Test code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?PHP
 
  // CREATE TEST ARRAY
  $a = array('a','b','c','d','e','f','g','h','i','j');
 
  // START TIMER ONE
  $TimerOne = benchmarkTimerStart();
 
  // CALL COUNT FUNCTION 1000000 TIMES
  for($i=0;$i<1000000;$i++)
  {
    count($a);
  }
 
  // STOP TIMER ONE
  $ResultOne = benchmarkTimerStop($TimerOne);
 
  // START TIMER TWO
  $TimerTwo = benchmarkTimerStart();
 
  // CALL SIZEOF FUNCTION 1000000 TIMES
  for($i=0;$i<1000000;$i++)
  {
    sizeOf($a);
  }
 
  // STOP TIMER TWO
  $ResultTwo = benchmarkTimerStop($TimerTwo);
 
  // PRINT RESULTS
  echo 'Count: '.$ResultOne.' Seconds<br />';
  echo 'SizeOf: '.$ResultTwo.' Seconds';
 
  // TIMER FUNCTIONS
  function benchmarkTimerStart()
  {
    $timeExplode = explode(" ", microtime());
    $time = $timeExplode[1] + $timeExplode[0];
    return $time;
  }
 
  function benchmarkTimerStop($timer=0)
  {
    $timeExplode = explode(" ", microtime());
    $time = $timeExplode[1] + $timeExplode[0];
    $finish = $time - $timer;
    $endTime = sprintf("%4.3f", $finish);
    return $endTime;
  }
?>

My test proved that there is no difference at all! sizeof() is just an alias for count().
So I suggest you to use count() - its the original name of this function.

So long,
Andreas Glaser (aka JaZz)

Leave a Comment :, , , , , , more...

PHP Online-Zeit Zähler

by Andreas Glaser on Jun.10, 2008, under Computer, Development, PHP

Vor ein paar Tagen wurde ich zum wiederholten mal gefragt, wie man einen Counter in PHP entwickelt, welcher die Dauer des Aufenthalt eines Besuchers auf einer Website ermitteln kann.

Der Ansatz

Um einen Online-Zeit Zähler zu programmieren muss man entweder Cookies oder Session Variabeln verwenden. Zudem, da PHP Serverseitig läuft kann man niemals zu 100% genau sagen wie lange sich ein Benutzer auf der Website aufhält. Desweiteren muss man sich auf eine Genauigkeit festlegen (bsp.: 60 Sec).

Der Code

Falls ihr Fragen dazu habt - einfach posten!

Andreas Glaser

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...