Home News Blog



MSN Random Online

A blog of all sections with no images
Lesson 13 - Creating custom functions PDF Print E-mail
Written by Administrator   
Thursday, 15 February 2007 17:57

Lesson 13 - Creating custom functions

By now, you should have yourself familiarized with the built-in PHP functions, if you don't, please go back and review them.  Again, the functions are located at http://www.php.net/quickref.php and you are encouraged to read through them and get yourself familiar with the many different actions you can perform with them.

One of the many functions in the PHP documentation is array_sum().  array_sum()'s documentation can be found at http://www.php.net/manual/en/function.array-sum.php.  What does array_sum() do?  It simply adds up all the number types in an array and returns the sum.  You should know how to use this function (from reading the documentation):

Code:
<?
$array = array(1,5.5,2.0,3,6,1);
echo array_sum($array); //prints "18.5"
?>

This is a clear example of what a function is there to do.  This function does a specific task and it saves us from having to repeat code (possibly from summing up several arrays).  Our task for this lesson is the create a NEW function which performs the exact same function as array_sum().  This will help us learn how to implement our own custom functions and also give us a better understanding of why we create functions.

The basic syntax of a function is the following:

function function_name($parameter_1,$parameter_2...$parameter_n) {
//do something with the parameters
//create a new variable ($variable)
return $variable
}

In case you're curious, this is what return does:  When you do "$variable = array_sum($array)", array_sum itself uses the "return" statement which returns a value which in turn you assign to $variable.

Because we want to keep this as simple as possible, we're going to go about making our function with the assumption that the contents of the array will always only be number types.  The first thing we want to do is create the body of our function.  What does this mean?  This means that if we had a variable (or variables), how would we go about doing the job we want to do?

So let's say we have our variable $array (of array type), and it contains numbers.  How do we go about adding all the numbers?

Code:
$variable = 0; //create our new variable to store the sum
foreach ($array as $element) { //pretend as if you already have $array
$variable += $element; //add the element to the variable holding the sum
}

We're already half way done; we've created the body of our function.  Let's give our function a name now.  In PHP, you cannot name functions which are built into PHP, or else you'll get an error stating you can redeclare the function.  Since the function we're duplicating is called array_sum(), we'll call our function array_sum_copy().  What variable(s) does our function need as input to do its job?  Well, above, we created the body of our code under the impression that an array ($array) was declared, so that is what we'll need as input.  Finally, what output does our function return?  Well, we know that the body of our function stores the sum of the array elements inside $variable, so that's what we'll want to return to the user of the function (using the "return" statement).

Now all we have to do is put our function together:

Code:
function array_sum_copy($array) {
  $variable = 0;
  foreach ($array as $element) { //pretend as if you already have $array
    $variable += $element;
  }
  return $variable;
}

Let's go back and once again look at what we did.  We selected a name for our function.  We found out what variables our function will need to work (the parameters).  We created the body of our function and used all the parameters of the function.  Finally we figured out what output we want to return and we used the "return" statement to return it.

And this is how it would look if we used it:

Code:
<?

$array = array(1,5.5,2.0,3,6,1);
echo array_sum_copy($array); //prints "18.5"

function array_sum_copy($array) {
  $variable = 0;
  foreach ($array as $element) { //pretend as if you already have $array
    $variable += $element;
  }
  return $variable;
}

?>

I will be doing one more of these in a few lessons, but I want to just note on a few things.  First, you can create a function that has SEVERAL parameters.  Second, a function can return SEVERAL values (this will be demonstrated later).  Finally, variables declared in a function will only exist in that function.  For example, we declared $variable to hold the sum of the array elements, but $variable will only exist within the block it was declared, nowhere else (unless otherwise stated).  This is where we get into scope, and I will be explaining how scope works in PHP in the next lesson. 
 
 
 
Lesson 14 - Variable scope and global declaration PDF Print E-mail
Written by Administrator   
Thursday, 15 February 2007 17:55

Lesson 14 - Variable scope and global declaration

This is a VERY basic introduction to scope; I neglected to mention a lot of things when writing this particular tutorial to try to keep things as simple as possible.

In PHP there is something called scope, which relates to variables.  When you declare variables, you declare them in a particular scope.  The scope is the area in which the variable is declared.  In PHP, you set your scope with curly braces (the { and } characters).  There are two particular types of scope, the global scope which refers to everything outside functions, and the local scope which refers to everything inside functions.

Code:
<?
//this is the global scope
function something() {
  //this is the local scope
}
?>

Variables you declare in the global scope cannot be used in the local scope, and variables declared in the local scope cannot be used in the global scope.  For example:

Code:
<?
//this is the global scope
$variable = 'Someone'; //declare a variable
something(); //call a function which SHOULD print out the variable
function something() {
  //this is the local scope
  print $variable; //print out the variable we set in the global scope
}
?>

The above code will print nothing.  We declared a variable in the global scope, and tried to use it in the local scope.  Of course what we could have done was pass the variable in through an argument:

Code:
<?
//this is the global scope
$variable = 'Someone'; //declare a variable
//call a function passing the variable to it which SHOULD print out the variable
something($variable);
function something($argument) { //get the argument passed into the function
  //this is the local scope
  print $argument; //print out the variable we got through the argument
}
?>

The above will print what we expect it to.  But what if we don't want to constantly pass variables inside?  Well you can always get your function to refer to the variable you want to use in the local scope from the global scope by declaring them as "global".  That may be hard to understand, so here is an example:

Code:
<?
//this is the global scope
$variable = 'Someone'; //declare a variable
something(); //call a function which SHOULD print out the variable
function something() {
  //this is the local scope
  //declare $variable as global;
  global $variable; //THIS LINE IS IMPORTANT
  print $variable; //print out the variable we set outside of this scope
}
?>

The above code will print what we expect it to ("Someone").  By declaring $variable as global inside our function (in the local scope), all references to that variable will refer to $variable in the global scope.  This means that if you declare variables in the global scope, you have one of two basic methods to use those variables inside functions: pass them in as arguments to your function, or declare them as global inside the function.  The superglobals ($_*) variables we learned about earlier, in lesson 11, bypass the scope rule.  Superglobals can be used ANYWHERE without having to declare them as global.  This is good because if a person for example submits information via the "POST" method, you won't have to constant declare them as global inside functions to use them.  You can ALSO use the $GLOBALS array to refer to variables in the global scope:

Code:
<?
//this is the global scope
$variable = 'Someone'; //declare a variable
something(); //call a function which SHOULD print out the variable
function something() {
  //this is the local scope
  print $GLOBALS['variable']; //print out the variable we set in the global scope
}
?>

Remember that the local scope includes all functions, and the global scope includes everything that isn't inside functions.  Read about it more (with more examples, and more methods) at http://www.php.net/manual/en/language.variables.scope.php

 

 
Lesson 15 - Variable referencing PDF Print E-mail
Written by Administrator   
Thursday, 15 February 2007 17:54

Lesson 15 - Variable referencing

In this lesson, we're going to tackle another function problem.  One of the functions in PHP that I personally don't like the functionality of is the sqrt() function.  Why don't I like how this function works?  Well it's because it takes in negative numbers, and it continues execution of your program. If you use the sqrt() function and use whatever number you get across your program, you'll get a ton of errors if you used a negative argument.  That's not to say it's bad, but the way I'd rather have it work is for it to exit the program in case the argument is negative.

So what I'll do is create my own sqrt() function, and call it squareroot() (since we can't override built in functions)

Again, first we'll have to come up with a name.  squareroot() as mentioned above seems appropriate.  We could always use a more condensed name like sqroot() or sqrt2(), but again, that's a style choice and you can choose whatever name you think is appropriate.

The next thing we'll have to do is decide what variables this function will require (through parameters/arguments).  This function will only require one variable - the number we wish to find the square root of.

Finally, we have to create the body of our function based on the variables we chose as parameters.  For the body, the code is fairly simple.  If the argument is less than 0, exit the program with an error (we can use the built-in die() function for this).  If the argument is any number greater or equal to 0, return the square root of that number.

Putting it all together, we get this:

Code:
function squareroot($num) {
  if ($num < 0) {
    die('error, cannot use negative number in squareroot()');
  } else {
    return sqrt($num);
  }
}

If the number is negative, the program will die and stop all execution.  Simple enough?

The second thing I want to give a little tutorial on is static variables.  When you normally run a function, any variables used inside that function quickly disappear after the function finishes executing.  Sometimes, under some circumstances, you may want those variables to stick around.  Here is a quick demonstration of that (recoded from the PHP documentation to use better variable names):

Code:
function continuous_count($num = 0) {
  static $current = 0;
  echo $current;
  $current += 1;
}

What this function will do is declare a variable as static inside a function, and continue to increment that variable every time the function is called.

So:

Code:
<?

function continuous_count($num = 0) {
  static $current = 0;
  echo $current;
  $current += 1;
}

continuous_count();
continuous_count();
continuous_count();
continuous_count();
continuous_count();

?>

would produce "01234"

There are a few things you should know about static variables.  First of all, they can't take on any expressions.  You cannot assign it something like "sqrt(16)" or "1+2" or anything that requires PHP to execute to get the value of.  Second of all, a static variable is only declared the first time a function is called.  On the first run of the above code, the variable $current is set to "0".  On the second run of the above code, since $current is already static and has a value, the line is skipped and the function continue to output and increment the variable.

 

 
Lesson 16 - More function examples PDF Print E-mail
Written by Administrator   
Thursday, 15 February 2007 17:53

Lesson 16 - More function examples

In this lesson, we're going to tackle another function problem.  One of the functions in PHP that I personally don't like the functionality of is the sqrt() function.  Why don't I like how this function works?  Well it's because it takes in negative numbers, and it continues execution of your program. If you use the sqrt() function and use whatever number you get across your program, you'll get a ton of errors if you used a negative argument.  That's not to say it's bad, but the way I'd rather have it work is for it to exit the program in case the argument is negative.

So what I'll do is create my own sqrt() function, and call it squareroot() (since we can't override built in functions)

Again, first we'll have to come up with a name.  squareroot() as mentioned above seems appropriate.  We could always use a more condensed name like sqroot() or sqrt2(), but again, that's a style choice and you can choose whatever name you think is appropriate.

The next thing we'll have to do is decide what variables this function will require (through parameters/arguments).  This function will only require one variable - the number we wish to find the square root of.

Finally, we have to create the body of our function based on the variables we chose as parameters.  For the body, the code is fairly simple.  If the argument is less than 0, exit the program with an error (we can use the built-in die() function for this).  If the argument is any number greater or equal to 0, return the square root of that number.

Putting it all together, we get this:

Code:
function squareroot($num) {
  if ($num < 0) {
    die('error, cannot use negative number in squareroot()');
  } else {
    return sqrt($num);
  }
}

If the number is negative, the program will die and stop all execution.  Simple enough?

The second thing I want to give a little tutorial on is static variables.  When you normally run a function, any variables used inside that function quickly disappear after the function finishes executing.  Sometimes, under some circumstances, you may want those variables to stick around.  Here is a quick demonstration of that (recoded from the PHP documentation to use better variable names):

Code:
function continuous_count($num = 0) {
  static $current = 0;
  echo $current;
  $current += 1;
}

What this function will do is declare a variable as static inside a function, and continue to increment that variable every time the function is called.

So:

Code:
<?

function continuous_count($num = 0) {
  static $current = 0;
  echo $current;
  $current += 1;
}

continuous_count();
continuous_count();
continuous_count();
continuous_count();
continuous_count();

?>

would produce "01234"

There are a few things you should know about static variables.  First of all, they can't take on any expressions.  You cannot assign it something like "sqrt(16)" or "1+2" or anything that requires PHP to execute to get the value of.  Second of all, a static variable is only declared the first time a function is called.  On the first run of the above code, the variable $current is set to "0".  On the second run of the above code, since $current is already static and has a value, the line is skipped and the function continue to output and increment the variable.

 

 
Lesson 17 - Regular Expressions PDF Print E-mail
Written by Administrator   
Thursday, 15 February 2007 17:52

Lesson 17 - Regular Expressions

Regular Expressions are one of the trickiest things to learn.  There are a lot of components to it, but it can at the same time be very strong.  A regular expression is an expression which lets you match an arbitrary strong, dissect it, and check it for validity.  A regular expression uses as set of characters to match strings someone inputs to them.  For those of you that have used DOS or the Unix shell, "dir *.txt" (for DOS) or "ls *.txt" are both regular expressions which ask that the dir/ls commands only return strings that end with ".txt" and have "any other character" before them.

Why would you want to use regular expressions in you're scripts?  The biggest reason would be to validate what a user inputs into fields in a HTML form and submits to your PHP script.  I won't go into the negatives, but for example, if you had the HTML field "age", you would only expect the user to input a number.  If the user inputs anything other than numbers, you don't want that information to go into your database.  You can use regular expressions to validate what the user inputs in the "age" field, and if they type in something bad, you can warn them.

The six basic simple characters used in regular expression are:

Pattern: a*
Matches: '', 'a', 'aa', ...
Explanation: match "a" zero or more times

Pattern: b+
Matches: 'b', 'bb', ...
Explanation: match "b" one or more times

Pattern: ab?c
Matches: 'ac', 'abc'
Explanation: match "a" followed by "b" optionally and then "c"

Pattern: [abc]
Matches: 'a' or 'b' or 'c'
Explanation: match "a" or "b" or "c" once

Pattern: [a-c]
Matches: 'a' or 'b' or 'c'
Explanation: Abbreviation for the above

Pattern: [abc]*
Matches: '', 'accb', ...
Explanation: Combination of "one from a set" and "zero or more"; match "a" or "b" or "c" zero or more times from the set

The "^" character is used to check to see whether something "starts at the beginning of the string".  The "$" character is used to check whether something "finishes at the end of the string".  The "|" character is used as the "or" separator.  The "|" character is not like the square bracket characters, because the | character separates regular expressions, NOT characters.  Brackets are used to group regular expressions.  Curly brackets are used to match regular expressions a certain amount of times (or a minimum/maximum amount of times).  I know this is a little too much to take it, but soon there will be a massive amount of examples to explain all of these regular expressions characters.

There are also a few special characters which are used to set common characters.  Those are:

\t -> Tab
\n -> Newline
\r -> Carriage Return
\* -> Asterisk
\\ -> Backslash
\d -> Digits [0-9]
\w -> Word [a-zA-Z0-9_] (letters, numbers, and the underscore)
\s -> Space [\t\r\n] (a tab, a carriage return, a newline)
. -> Anything except end-of-line [^\n] (literally any character that isn't a newline)

The function used in PHP to match a string using regular expressions is the preg_match() function.  This function uses Perl's regular expression feature to match a string.  The function takes the following [simple] parameters:

int preg_match (string pattern, string subject)

The "pattern" must start and end with the "/" character.  The main reason for this is that this function uses the Perl regular expressions library, and Perl uses "/"'s in its functions (if you used Perl, regular expressions don't use functions, instead they use m///).  The function returns a 1 if the "pattern" matched something in the "subject" and 0 otherwise.

Here are a few simple examples:

Code:
echo preg_match("/a/", "a"); //matches "a"
echo preg_match("/b/", "a"); //doesn't match, needs a "b"
echo preg_match("/a+/",""); //doesn't match, needs to have at least 1 "a"
echo preg_match("/a+/","a"); //matches, at least one "a"
echo preg_match("/a+/","aaaaaa"); //matches, at least one "a"
echo preg_match("/a*/",""); //matches, 0 or more "a"'s
echo preg_match("/a*/","aaaaaaaaaa"); //matches, 0 or more "a"'s
echo preg_match("/[xyz]/","x"); //matches, there is an "x"
echo preg_match("/[xyz]/","y"); //matches, there is an "y"
echo preg_match("/[xyz]/","z"); //matches, there is an "z"
echo preg_match("/[xyz]/","a"); //doesn't match, there is neither "x", "y", or "z"
echo preg_match("/[a-z]/","q"); //matches, "q" is in the range from "a" to "z"
echo preg_match("/[0-9]/","5"); //matches, "5" is in the range from "0" to "9"
echo preg_match("/[0-9]/","s"); //doesn't match, "s" is not in the range from "0" to "9"

examples of the "|" character:

Code:
//note that the | does not match only the chararacter before or after,
//the | character matches everything either before or after unless you group
//them

//not grouped
echo preg_match("/ab|cd/","ab"); //matches
echo preg_match("/ab|cd/","cd"); //matches

//grouped
echo preg_match("/a(b|c)d/","abd"); //matches
echo preg_match("/a(b|c)d/","acd"); //matches
echo preg_match("/a(b|c)d/","ad"); //doesn't match

examples of the "*" character:

Code:
echo preg_match("/ab*/","abbbb"); //matches
echo preg_match("/ab*/","bbbbb"); //fails

examples of the "+" character:

Code:
echo preg_match("/a+b/","aaaab"); //matches
echo preg_match("/a+b/","b"); //fails

examples with "\w" character:

Code:
echo preg_match("/\w+/","abc"); //matches
echo preg_match("/\w+/","a_b_c"); //matches
echo preg_match("/\w+/","0123456789"); //matches
echo preg_match("/\w+/","-"); //fails, "-" is not a part of \w
echo preg_match("/\w+/"," "); //fails, space is not a part of \w
echo preg_match("/\w+/",""); //fails, have to have a least one \w

examples with "?" character:

Code:
echo preg_match("/a?b?c?/","a"); //matches
echo preg_match("/a?b?c?/","b"); //matches
echo preg_match("/a?b?c?/","c"); //matches
echo preg_match("/a?b?c?/","abc"); //matches
echo preg_match("/a?b?c?/","ab"); //matches
echo preg_match("/a?b?c?/","bc"); //matches

examples with "^" and "$" characters:

Code:
echo preg_match("/^im/","image"); //matches
echo preg_match("/^im/","imagine"); //matches
echo preg_match("/^im/","embrace"); //doesn't match
echo preg_match("/er$/","programmer"); //matches
echo preg_match("/er$/","designer"); //matches
echo preg_match("/er$/","designing"); //doesn't match
echo preg_match("/^(ab|cd)$/","ab"); //matches
echo preg_match("/^(ab|cd)$/","cd"); //matches
echo preg_match("/^(ab|cd)$/","abcd"); //doesn't match
echo preg_match("/^(ab|cd)$/","xy"); //doesn't match

examples with curly brackets character:

Code:
echo preg_match("/a{2}/","aaa"); //matches, found "aa" somewhere
echo preg_match("/^a{2}$/","aa"); //matches, entire string is "aa"
echo preg_match("/^a{2}$/","aaa"); //doesn't match, entire string isn't "aa"
echo preg_match("/a{2,4}/","aaa"); //matches, minimum "aa", maximum "aaaa"
echo preg_match("/a{2,4}/","aaaa"); //matches
echo preg_match("/a{2,4}/","a"); //doesn't match
echo preg_match("/^a{2,4}$/","aabaa"); //doesn't match

a few common regular expressions (these are by no means secure... JUST simple):

Code:
echo preg_match("/^[-.\w]+\@[-.\w]+$/","
 This e-mail address is being protected from spambots. You need JavaScript enabled to view it
 "); //email addresses
echo preg_match("/^\d{2}$/","24"); //ages
echo preg_match("/^(19|20)\d\d$/","1983"); //years
echo preg_match("/^([\w\s]+)$/","hello there"); //a simple string
echo preg_match("/^(http:\/\/www\.|http:\/\/|www\.)([\w\.\/\=\?\&\-]+)$/","http://www.google.com"); //urls

 

 
Lesson 18 - Filesystem functions PDF Print E-mail
Written by Administrator   
Thursday, 15 February 2007 17:50

Lesson 18 - Filesystem functions

Filesystem Functions

The filesystem functions in PHP allow you to manipulate files.  You can open file, write to files, and updates files as you see fit with this set of functions.  The four main functions (at least in my opinion) for this group of functions are:

fopen - open a file to work with
fread - read the contents of a file
fwrite - write some content to a file
fclose - close a file you were working with

Using these functions is no different from using any other functions.  You simply have to read the documentation to learn about their arguments and what they return.  Please note the following URLs for references to the functions you will see in this tutorial.

http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.fread.php
http://www.php.net/manual/en/function.fwrite.php
http://www.php.net/manual/en/function.fclose.php

If your scripts are running on a Unix operating system, you have to take extra care to see if you're allowed to read/write to the file you're trying to access.  When opening a file, you must always pass as arguments the location of the file your trying to open (either relative or absolute) and what you want to do with that file (read/write/append).

When opening files, these are the extra arguments you should be aware of (not all were included):
'r' - Open for reading only; place the file pointer at the beginning of the file.  If the file doesn't exist, you'll get an error.
'r+' - Open for reading and writing; place the file pointer at the beginning of the file.  If the file doesn't exist, you'll get an error.
'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.  Note that when writing, you lose all the other content in the file - you overwrite.
'w+' - Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.  Note that when writing, you lose all the other content in the file - you overwrite.
'a' - Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'b' - binary.  This little mode can take up about 4 paragraphs of explanation as the PHP documentation clearly shows.  This mode must be the last letter if your mode consists of several of the above.

For example, to open a file just to read:

Code:
$filehandle = fopen('/path/to/file', 'r');

If you were on a windows platform and the file wasn't a standard text file, this would be a more suitable line:
Code:
$filehandle = fopen('/path/to/file', 'rb'); //b for binary

To write to a file or append to a file, these might be suitable lines of code:
Code:
$filehandle = fopen('/path/to/file', 'w'); //write to the file
$filehandle = fopen('/path/to/file', 'a'); //append to the file

fopen can also take a URL as an argument, but you can only read ('r' argument) from a URL, you cannot write/append to one.  After opening a file to read/write/append to, you can begin working with it using fread/fwrite.

PHP reads files in chunks (bytes).  When reading from a file, you must specify how many bytes you want to read.  You can read the entire file into memory, or you can read it in chunks.  The two examples given below show both methods (these two methods are very standard):

Read the entire file all at once
Code:
$filehandle = fopen('/path/to/file', 'rb');
$contents = fread($filehandle, filesize('/path/to/file'));

Read the file in portions
Code:
$filehandle = fopen('/path/to/file', 'r'); //open the file in read mode 
while (!feof($filehandle)) { //is there more to read?
  $contents .= fread($filehandle, 1024); //read the file in 1 meg portions
}
note: feof() tests to see if we've reached the end of the file yet

Remember that when you write to a file, you must have permission to do so.  Writing or appending to a file is as simple as:

Write:
Code:
$filehandle = fopen('/path/to/file', 'w'); //write
fwrite($filehandle, 'new contents of file'); //fputs() can be used as well

append:
Code:
$filehandle = fopen('/path/to/file', 'a'); //append
fwrite($filehandle, 'new contents added at the end of the file'); //fputs() can be used as well

If you wish to add new lines to a file, you can simply use "\n" to go to the next line.  Please remember that you'll need to either concatenate "\n" or include "\n" in double quotes with all your text so it gets interpolated into the newline character.

After you open a file with fopen, and you read/write contents using fread/fwrite, you should ALWAYS close the file.  This doesn't take any extra effort.  Remember to always include code like:

Code:
fclose($filehandle);

If you don't close your file (with the filehandle) after you finish working with it, you risk problems occurring.  If you don't close a file after writing to it, you risk the contents of the file being lost.  If you open a file, but don't close it, you also risk corrupting the file (which means you'll lose partial or all parts of the file).

Extra notes:
- If you try to open a file to write/append to, and it doesn't exist, PHP will try to create it
- Depending on which operating system you're working on, you might have to use "\r\n" (carriage return and newline) to go to the next line.  If you don't open your files in binary mode (mode b), this will transparently be done for you.  Please refer to the PHP documentation located at http://www.php.net/manual/en/function.fopen.php for a clear explanation of when and how to use binary mode.
- You can open webpage URLs to read, but not to write.  You can open FTP URLs to read and write to.  Make sure to use the proper formatting for FTPs: "ftp:// username:password @ url.com"
- You must have permission to read/write to a file.  PHP reads and writes to files as user 'nobody'.  This is different from root access to the files.  A file created by the root does not belong to 'nobody', but a file created by 'nobody' does belong to the root.
- If you don't have root access or someone hosts your website for you, chances are you don't have root access.  Creating files through ftp and files through a PHP scripts are two different things, and neither has privileges to touch the other.  If you create a file with PHP, you cannot delete it with FTP software and visa versa.  Simple rule to remember is: "if it made it, it must take care of it"
- you can use file() to read the contents of a file or URL into an array.  You can use file_get_contents() to read an entire file into a variable.  Both functions are binary safe now so they should handle line endings properly.

 

 
«StartPrev12345678910NextEnd»

Page 9 of 24
 

Top Members

No top members yet.