The last thing I'm going to show you is how you can capture the state of your
application without terminating the script. This is done by using the error log
function. The error log function allows you to capture the state of your browser
through the use of a string and send it to a log file where you can view it
later on. This is done by using the error log function, which takes three
parameters. First, it takes some sort of text, a message that you can catenate
or put together. Then it takes one of four integers. The meaning of the
different integers are documented in the PHP manual online. In this case we're
going to use three, which is the most common. The integer three means go ahead
and just append the current message onto the existing file. The last one's going
to be the path to the file and the name of the file. Now, when you specify the
name and the path of your file, you need to be aware that the web server is the
one that's executing the script so it needs to have write permissions to that
file and director. Which directory and which text file you use depends upon
which web server and which operating system that web server is running on. In
this instance, we're using Mac OS 10 and the Apache web server and a very good
place to create your log file in Mac OS 10 is inside the temp director. The temp
directory is at forward slash tmp forward slash. When I go to that directory,
you can see that I currently have an item there that's placed there by another
application or by the operating system. And this is where I'm going to create my
log file. I'm going to say error log, and the message is going to be text, and
the path is going to be forward slash tmp and the name of the file is going to
be error log.txt. Now, the web server will try to append my current message and
if the error log doesn't exist, it will create it. Let's go ahead then and
refresh this in the browser. And watch the temp directory. Here's my error log.
When I open it up, you can see my message. So you can place inside of your error
log function whatever kind of message is going to be helpful for you as the
programmer and administrator to help debug your application or to monitor its
status. Inside this message you could do something like create the current UNIX
time stamp and concatenate that with a message and a new line return. Now go
ahead and close our log and refresh this a few more times so that the browser
has executed this script several times. And we'll open up our error log. In here
we can see that we now have a Unix time stamp prepending our message and then a
new line return so that the next error log entry is forced onto its own new line.
So, as you can see, with a little bit of imagination you could create quite an
extensive log file and you can use the error log function at any point during
your application. So I could bump this line of code up to one of my loops and
even put variables inside here that says X is equal to X, and I is equal to the
variable I. And then again, refresh this in the browser and get a very verbose
log file. So with the error log function, you can capture the status of your
current PHP application and you can log your entries for administrative or
debugging purposes. It's even nice to be able to create the error log function
inside of your own custom function that maybe perhaps looks for a variable or a
constant that you've defined to see if you want debugging turned on or turned off.
That way you can go into a certain included file and set a constant or a variable
to on or off dependent upon whether or not you want logging to occur during the
running of your application or not. So here's how you can capture your current
PHP application and how you can terminate your scripts and concludes this lesson.
FileMaker 9 and PHP
Lance Hallberg
US$ 99.95
8 hours - 107 Movies
Win Vista XP 2000,ME. Mac OS X
Ground / 2 day / Next Day
33786
258 In Stock
Apex Web Media ( Hyperteach ) P.O Box 398 Bolton BL7 9YS, United Kingdom. Tel: +44 (0) 1204 592071 Fax: +44 (0) 1204 592092 Email:
Apex Web Media ( Hyperteach ) 600 17th Street, Suite 2800, Denver CO 80202 Tel: Toll free 1866 402 1903 (USA) / 434 878 4158 Fax: 1 207 433 4356 Email: