$a = $array("a"=> 1, "b"=> 2);
now type cast array in to object...
$arrayObj = (object)$a;
now u able to use like object and method.....
echo $arrayObj->a; // output 1
echo $arrayObj->b;// output 2
but only work with key as a string.....not work with indexed array.
Saturday, June 7, 2008
How to get current date..in PHP..?????
just simple
use a inbuilt PHP date() function and pass the time() function as a parameter....
like...
echo date("y/m/d",time());
first parameter is date format.
and second is PHP inbuilt time() function.
use a inbuilt PHP date() function and pass the time() function as a parameter....
like...
echo date("y/m/d",time());
first parameter is date format.
and second is PHP inbuilt time() function.
List of Output Control Functions in PHP 5
o flush — Flush the output buffer
o ob_clean — Clean (erase) the output buffer
o ob_end_clean — Clean (erase) the output buffer and turn off output buffering
o ob_end_flush — Flush (send) the output buffer and turn off output buffering
o ob_flush — Flush (send) the output buffer
o ob_get_clean — Get current buffer contents and delete current output buffer
o ob_get_contents — Return the contents of the output buffer
o ob_get_flush — Flush the output buffer, return it as a string and turn off output
buffering
o ob_get_length — Return the length of the output buffer
o ob_get_level — Return the nesting level of the output buffering mechanism
o ob_get_status — Get status of output buffers
o ob_gzhandler — ob_start callback function to gzip output buffer
o ob_implicit_flush — Turn implicit flush on/off
o ob_list_handlers — List all output handlers in use
o ob_start — Turn on output buffering
o output_add_rewrite_var — Add URL rewriter values
o output_reset_rewrite_vars — Reset URL rewriter values
o ob_clean — Clean (erase) the output buffer
o ob_end_clean — Clean (erase) the output buffer and turn off output buffering
o ob_end_flush — Flush (send) the output buffer and turn off output buffering
o ob_flush — Flush (send) the output buffer
o ob_get_clean — Get current buffer contents and delete current output buffer
o ob_get_contents — Return the contents of the output buffer
o ob_get_flush — Flush the output buffer, return it as a string and turn off output
buffering
o ob_get_length — Return the length of the output buffer
o ob_get_level — Return the nesting level of the output buffering mechanism
o ob_get_status — Get status of output buffers
o ob_gzhandler — ob_start callback function to gzip output buffer
o ob_implicit_flush — Turn implicit flush on/off
o ob_list_handlers — List all output handlers in use
o ob_start — Turn on output buffering
o output_add_rewrite_var — Add URL rewriter values
o output_reset_rewrite_vars — Reset URL rewriter values
List of Predefined variables in PHP 5 and PHP 4
PHP5 and PHP4 provides a large number of predefined variables to all scripts.
* Superglobals — Superglobals are built-in variables that are always available in all scopes
* $GLOBALS — References all variables available in global scope
* $_SERVER — Server and execution environment information
* $_GET — HTTP GET variables
* $_POST — HTTP POST variables
* $_FILES — HTTP File Upload variables
* $_REQUEST — HTTP Request variables
* $_SESSION — Session variables
* $_ENV — Environment variables
* $_COOKIE — HTTP Cookies
* $php_errormsg — The previous error message
* $HTTP_RAW_POST_DATA — Raw POST data
* $http_response_header — HTTP response headers
* $argc — The number of arguments passed to script
* $argv — Array of arguments passed to script
* Superglobals — Superglobals are built-in variables that are always available in all scopes
* $GLOBALS — References all variables available in global scope
* $_SERVER — Server and execution environment information
* $_GET — HTTP GET variables
* $_POST — HTTP POST variables
* $_FILES — HTTP File Upload variables
* $_REQUEST — HTTP Request variables
* $_SESSION — Session variables
* $_ENV — Environment variables
* $_COOKIE — HTTP Cookies
* $php_errormsg — The previous error message
* $HTTP_RAW_POST_DATA — Raw POST data
* $http_response_header — HTTP response headers
* $argc — The number of arguments passed to script
* $argv — Array of arguments passed to script
PHP5 Encapsulation Surprises to you ..........
In PHP5, unlike Java or C++, $this has to be explicitly used to refer to variables within a
class.
The value of $this is determined by the context in which it is called. In certain situations
$this may actually refer to the invoking class rather then the current class. This breaks object
encapsulation.
$this pseudo-variable is not defined if the method in which it is located is called statically
with an exception as noted below.
$this is defined if a method is called statically from within another object. In this case, the
value of $this is that of the calling object.
The following example from PHP manual will clarify this:
foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>
Output:
$this is defined (a)
$this is not defined.
$this is defined (b)
$this is not defined.
class.
The value of $this is determined by the context in which it is called. In certain situations
$this may actually refer to the invoking class rather then the current class. This breaks object
encapsulation.
$this pseudo-variable is not defined if the method in which it is located is called statically
with an exception as noted below.
$this is defined if a method is called statically from within another object. In this case, the
value of $this is that of the calling object.
The following example from PHP manual will clarify this:
foo();
A::foo();
$b = new B();
$b->bar();
B::bar();
?>
Output:
$this is defined (a)
$this is not defined.
$this is defined (b)
$this is not defined.
Subscribe to:
Posts (Atom)