Aviv Ronen Blog

Jul 15 2008

PHP ociparse Error Handling

ociparse

(PHP 4, PHP 5, PECL oci8:1.0-1.2.4)

ociparse — Alias of oci_parse()

Description

This function is an alias of: oci_parse().


 

$stmt = OCIParse($conn, $query);
if (!$stmt) {
   $err = OCIError($conn);
   echo “Error:”.$err[”message”];

}


Jun 23 2008

Simple PHP Exception Handling explanation

What is an Exception

Finaly, with php5 came a new object oriented way for dealing errors,
if a specified error (exceptional) condition occurs exception handling is used to change the
flow of the code execution .

Exceptions are a great tool and should only be used with error conditions,
dont ever use them to jump to another place in the code at a specified
point - you cant know what will happend.

Basic Use of php5 Exceptions

When an exception is thrown, PHP will try to find the matching “catch” block.

The bad way:

<?php
 function checksum($number1=NULL,$number2=NULL)
   {
       if($number1===NULL OR $number2===NULL)
          {
  throw new Exception("Value must not be NULL");
 }
   return true;
  }
 checksum(7,NULL);
 ?>

The good way:

Good Luck! use this php5 tool smartly.


Apr 10 2008

Migration to PHP5

1) Improve performance
2) Fully Web2 Integration
3) PHP4 Is 8 years old! Old! Old!
4)Proven in  business critical deployment
5) Php5 Is Designed for Modern Web Applications (Json,Web Services ech)
6)New Zend Engine (Version 2) - Up to 4X Faster
7) New object Model (Design Pattern, Cloning ech)
8) better Memory management
9) Great XML Support (Simple XML,DOM ech)
10)Very Easy Soap!

 More Information available at:

http://www.zend.com/webinar/PHP/webinar-php4-php5-migration-20080326.flv


Apr 10 2008

Some PHP 4 Facts!

1) Php4 was born in 2000

2) PHP4 Security fix will be available until 8 August 2008

3) PHP4 Support ended in 1.1.2008

4) PHP4 will always be available for download

5) PHP5 Is already 3 years old!

So, Why are you still using PHP4, migrate to 5 ASAP


Apr 01 2008

PHP Easter Egg / 1 April

Well, it just so happens that if you add this string :
?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
 at the end of any URL that is a PHP page (www.somewebsite.com/somephppage.php?=PHPE9568F36-D428-11d2-A769-0z0AA001ACF42) you will see a funny little picture of a dog.
for every version of PHP there is a difference image

php-terrier-dog.gifphp-rabbit.gifphp-dude.gifphp-dog.gifphp-colored.gif

For example: http://www.php.net/downloads.php?=PHPE9568F36-D428-11d2-A769-00AA001ACF42

 Basically, every PHP expert know that there are 4 famous queries you can send to a PHP page:

Query 1 - ?=PHPE9568F36-D428-11d2-A769-00AA001ACF42
This is the most interesting and funny query,  displays an funny image.

Query 2 - ?=PHPE9568F35-D428-11d2-A769-00AA001ACF42
Used by PHPINFO to show the Zend Logo, it will work on any php page

Query 3 - ?=PHPE9568F34-D428-11d2-A769-00AA001ACF42
Used by PHPINFO to show the Zend Logo, it will work on any php page.

Query 4 - ?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
shows the PHP development credits.

 

Also, if you will look at the PHPINFO at 1 in April, the PHP Logo is replaced by the funny images above.

 

enjoy,

Aviv