Developers Archive for the 'php function explanations' Category

get_defined_functions

get_defined_functions Monday, January 22nd, 2007

get_defined_functions:
This function used to get all internal and user defined functions in that php file. functions in include files also listed as used defined funtion.

Syntax:
array get_defined_functions();

Example:
<?php
function fun1(){
fun1_body

}
function fun2()
{
fun2_body
}
$fun=get_defined_functions();
print_r($fun);
?>

Output:

Array
(
[internal] => Array
(
[0] => zend_version
[1] => func_num_args
[2] => func_get_arg
[3] => func_get_args
[4] => strlen


[user] => Array
(
[0] => fun1
[1] => fun2
)
)

Top 5 new features in PHP5

Top 5 new features in PHP5 Monday, January 22nd, 2007

5: Better error handling with exceptions
I’m sure every PHP developer had been staring at the famous white screen with a “Syntax error” clueless at where the error is really at. With PHP5, you can actually handle PHP errors and do whatever you want with them, but that’s not all. They have also included exceptions which I’m sure most C++ or Java developers use. The good part is that instead of simply failing on with close no errors to you, you could put a few checks before and information you could need such as maybe a print_r() on an array.
4: Completely rewritten MySQL extension
The MySQL databases are the PHP’s partner in crime. Many developers use this database system in their website’s because it is on of the easiest, free, open-source database software. However, its performance combined with PHP4 was close to poor. Introduced with PHP5 is a newer, rewritten, optimized MySQL extension which was also compatible with MySQL 5.0. It has also introduced other functions such as: Prepared statements, SSL connections, Multi-query functions.

3: A heck of a lot more useful functions
I have a few favorite PHP5 functions which speed up time while coding & enhances the website’s performance. One of my favorites is the __autoload() function – What it does that it would be called if a class that was created and did not exist. It provides you with the class name. This is useful because you don’t need to manage what includes you need for X and Y file and reduces the load for those who simply include all the classes in for every single PHP file. Also, another favorite is file_put_contents() which reduces the 6 lines of code to add something to one.

2: Finally! SQLite database support!
I’m sure a lot of developers will be happy about this one. While MySQL is very popular among most PHP developers, SQLite is much different than it. It actually uses normal files and reads them. It does not need a daemon (or called server) to run in order to execute any queries on it. It makes a better smaller database for these low traffic sites.

1: The best damn OOP support period
PHP programmers have spent an awful of long time trying to create hacks so in order that PHP can make a better OO programming language. Finally, they are rewarded with OO support that either PHP3 or PHP4 can match. It has anything you usually see in most of the other established coding languages. From Constructors, Destructors, Public, protected, private properties & methods, Interfaces, Abstract classes, Class type hints, Static properties and methods, Final properties and methods & a whole suite of magical methods.

Array_intersect function:

Array_intersect function: Friday, January 19th, 2007

This function is used to computes the intersection of arrays

array array_intersect ( array array1, array array2 [, array …])
Example

<?php

$arr1 = array (”a” => “test1″, “test2″, “test3″);

$arr2 = array (”b” => “test2″, “test4″, “test1″);

$result = array_intersect ($arr1, $arr2);

print_r($result);

//result array will be like this

Array([a]=>test1 [0]=>test2)

?>


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.