With the exif (Exchangeable Image Information) extension in php you can work with image meta data. Whenever you use any digital camera and take an image meta data information is stored in the image (like image type, resolution, size etc). With php you can extract that information.
Requirements to use exif extention
To enable exif-support, configure PHP with --enable-exif on unix platform.
If you are on windows platform then uncomment the
php_mbstring.dll and
php_exif.dll DLL's in php.ini. Be sure that php_mbstring.dll DLL must be loaded before the php_exif.dll DLL.
List of exif functions
1)exif_imagetype: It read metadata information from image and determines the type of the image (like jpg, gif, bmp etc). The syntax is,
int exif_imagetype ( string $filename );
The possible return values are,
Value Constant
1 IMAGETYPE_GIF
2 IMAGETYPE_JPEG
3 IMAGETYPE_PNG
4 IMAGETYPE_SWF
5 IMAGETYPE_PSD
6 IMAGETYPE_BMP
7 IMAGETYPE_TIFF_II (intel byte order)
8 IMAGETYPE_TIFF_MM (motorola byte order)
9 IMAGETYPE_JPC
10 IMAGETYPE_JP2
11 IMAGETYPE_JPX
12 IMAGETYPE_JB2
13 IMAGETYPE_SWC
14 IMAGETYPE_IFF
15 IMAGETYPE_WBMP
16 IMAGETYPE_XBM
You can access image type by CONSTANTS also. If the function could not find any it will return FALSE.
2)exif_read_data: This functions returns many information like height, width, digital camera information, copyright information etc of the image after reading the header info of the image.
The syntax is,
array exif_read_data (string $filename , [string $sections= NULL] , [bool $arrays= false] , [bool $thumbnail= false]);
file_name -is the name of the image file for which you want to extract information.
sections part is the combination of
FILE (FileName, FileSize, FileDateTime, SectionsFound)
COMPUTE (html, Width, Height, IsColor, and more)
IFD0 (Image size and others)
THUMBNAIL
COMMENT (Comment headers of JPEG images.)
EXIF (detail info of the image)
arrays -sepecify whether each section becomes an array)
thumbnail- If true then thumbnail itself is read.
3)exif_tagname: It takes image index and return header name.
The syntax is, string exif_tagname ( int $index );
4)exif_thumbnail: It retrieves the embedded thumbnail of either tiff or jpeg type image.
The syntax is,
string exif_thumbnail(string $filename, [int &$width], [int &$height,[int &$imagetype);
5)read_exif_data: It is same as exif_read_data.
All these examples are given in the post
Friday, March 20, 2009
Image processing in php with exif extension
| Reactions: |
Access violation at address in module libmysql.dll. read of address 00000000
Problem Description
You have installed XAMPP and it was working fine. After restarting your windows it appeared "access violation at address 10002832 in module 'LIBMYSQL.dll'. Read of address 00000000" message popping up over and over again.
Even when you stop the MySql service in the XAMPP panel the messages keep on coming about one every 10 seconds.
But whenever you right-click on the traffic-light in the list of running programs and choose "Win NT>shutdown this tool" then everything works fine again after starting up the MySql service in the XAMPP control panel.
Cause of the Problem
In XAMPP installation MySQL by default install with the user root with no password. Later you changed password of WinMySQLAdmin but the change did not affect in MySQL and hence above pop up windows appears.
Solution of the Problem
1) Open WinMySQLamin. You can usually find it as traffic light on the taskbar. Right click on it and select show me.
2) On the Environment tab select "Set Server's Query Interval". A pop up window will appear. In the "Interval Query Setup" pop up window set a bigger value like 100.
3)Click on "my.ini setup" tab on your WinMySQLamin. In the box you will see password field. Make it null that means remove password from there.
4)Then click "save modification" on the left. Pop up window will appear and save it.
At this stage I hope your problem is disappeared and no pop up window is coming.
If the solution works for you then you have the two options to think.
1. If you are satisfied with it that is leaving password field blank of root user then nothing you need to do. Though it is bad practice to set root password blank.
2. Leave winMySQLAdmin like it is, and rather go and change MySQL to have root and password of the password that is set in WinMySQLAdmin.
You have installed XAMPP and it was working fine. After restarting your windows it appeared "access violation at address 10002832 in module 'LIBMYSQL.dll'. Read of address 00000000" message popping up over and over again.
Even when you stop the MySql service in the XAMPP panel the messages keep on coming about one every 10 seconds.
But whenever you right-click on the traffic-light in the list of running programs and choose "Win NT>shutdown this tool" then everything works fine again after starting up the MySql service in the XAMPP control panel.
Cause of the Problem
In XAMPP installation MySQL by default install with the user root with no password. Later you changed password of WinMySQLAdmin but the change did not affect in MySQL and hence above pop up windows appears.
Solution of the Problem
1) Open WinMySQLamin. You can usually find it as traffic light on the taskbar. Right click on it and select show me.
2) On the Environment tab select "Set Server's Query Interval". A pop up window will appear. In the "Interval Query Setup" pop up window set a bigger value like 100.
3)Click on "my.ini setup" tab on your WinMySQLamin. In the box you will see password field. Make it null that means remove password from there.
4)Then click "save modification" on the left. Pop up window will appear and save it.
At this stage I hope your problem is disappeared and no pop up window is coming.
If the solution works for you then you have the two options to think.
1. If you are satisfied with it that is leaving password field blank of root user then nothing you need to do. Though it is bad practice to set root password blank.
2. Leave winMySQLAdmin like it is, and rather go and change MySQL to have root and password of the password that is set in WinMySQLAdmin.
| Reactions: |
Operators in php
In simple definition an operator is something that takes one or more values and generates another value. Operators can be of three types.
1)Unary Operator: Which operates on just one value. Like incremental operator (++) or negation operator(!).
2)Binary Operator: Which operates on two values. In php most of the operators are binary operators. Like +, -, * etc.
3)Ternary Operator: Which operators on three values. Example is ? : combination.
like, the expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Based on the operator functionality it can be categorized into following:
1) Arithmetic Operators: Some basic arithmetic operator falls within this category.
Examples are -(negation -$a), +(addition $a+$b), -(subtraction $a-$b), * (multiplication $a*$b), division ($a/$b), modulus ($a%$b) where a and b are both variable. Note that Remainder $a % $b is negative for negative $a.
2) Assignment Operators: The = (equal sign) is the basic assignment operator. Whenever you write $a=$b it mean value of right hand variable b(operand) will be assigned to the left hand variable a.
3) Bitwise Operators: There are several bitwise operator that operates bit by bit between operands. These operators are below and beside the operator is the result.
& (bitwise AND - bit is set if both operands are set)
| (bitwise OR - bit is set if any of the operand is set)
^ (bitwise XOR - bit is set if bit is set in either of the operands but not when both are set)
~ (NOT) - bit is set if it is not set in the operator and vice-versa.
<< (Shift Left) - &a<<&b means shifts the bit of $a by $b steps to the left. >> (Shift Right) - &a>>&b means shifts the bit of $a by $b steps to the right.
4) Comparison Operators: Comparison operators are for comparing between two values. They returns boolean value.
Examples are,
== ($a==$b returns true if $a is equal to $b)
=== ($a===$b returns true if $a is equal to $b and $a has the same datatype as of $b)
!= or <> ( $a!=$b or $a<>$b will return true if $a is not equal to $b)
!==($ a!== $b will return true if $a is not equal to $b, or they are not of the same type.
< ($a < $b will return true if $a is less than $b.) > ($a > $b will return true if $a is strictly greater than $b.)
<= ($a <= $b will return true if $a is less than or equal to $b.) >= ($a >= $b will return true if $a is greater than or equal to $b.
5) Error Control Operators: The @ (at sign) is error control operator in php. If @ is prepend to variables, function, include() calls, constants then any error messages that might be generated by that expression will be ignored.
If the track_errors feature is enabled- which can be enabled by setting TRACK_ERRORS, any error message generated by the expression will be saved in the variable $php_errormsg. This variable will be overwritten on each error occurs.
6) Execution Operators: With php OS command can by executed by execution operator. If the commands are within backticks (` `) then PHP will attempt to execute the contents of the backticks as a shell command. Example is echo `ls -l`.
The backtick operator is disabled when safe mode (safe_mode =ON) is enabled or shell_exec() is disabled.
7) Incrementing/Decrementing Operators: Four incremental/decremental operators there.
++$a : Increments $a by one, then returns $a.
$a++ : Returns $a, then increments $a by one.
--$a : Decrements $a by one, then returns $a.
$a-- : Returns $a, then decrements $a by one.
8) Logical Operators:
AND : $a and $b becomes TRUE if both $a and $b are TRUE.
OR : $a or $b becomes TRUE if either $a or $b is TRUE.
XOR : $a xor $b becomes TRUE if either $a or $b is TRUE, but not both.
! : ! $a becomes TRUE if $a is not TRUE.
&& : $a && $b becomes TRUE if both $a and $b are TRUE.
|| : $a || $b becomes TRUE if either $a or $b is TRUE.
9) String Operators: One string type operation is concatenation(.) operator that concatenate it's left and right arguments. Another one is concatenating assignment operator ('.='), which appends the argument on the right side to the argument on the left side.
10) Array Operators: They work on array and examples are +,==,===, !=, <>,!== .
11) Type Operators: Example is, instanceof - which can be used to determine whether a variable is an instantiated object of a class.
1)Unary Operator: Which operates on just one value. Like incremental operator (++) or negation operator(!).
2)Binary Operator: Which operates on two values. In php most of the operators are binary operators. Like +, -, * etc.
3)Ternary Operator: Which operators on three values. Example is ? : combination.
like, the expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Based on the operator functionality it can be categorized into following:
1) Arithmetic Operators: Some basic arithmetic operator falls within this category.
Examples are -(negation -$a), +(addition $a+$b), -(subtraction $a-$b), * (multiplication $a*$b), division ($a/$b), modulus ($a%$b) where a and b are both variable. Note that Remainder $a % $b is negative for negative $a.
2) Assignment Operators: The = (equal sign) is the basic assignment operator. Whenever you write $a=$b it mean value of right hand variable b(operand) will be assigned to the left hand variable a.
3) Bitwise Operators: There are several bitwise operator that operates bit by bit between operands. These operators are below and beside the operator is the result.
& (bitwise AND - bit is set if both operands are set)
| (bitwise OR - bit is set if any of the operand is set)
^ (bitwise XOR - bit is set if bit is set in either of the operands but not when both are set)
~ (NOT) - bit is set if it is not set in the operator and vice-versa.
<< (Shift Left) - &a<<&b means shifts the bit of $a by $b steps to the left. >> (Shift Right) - &a>>&b means shifts the bit of $a by $b steps to the right.
4) Comparison Operators: Comparison operators are for comparing between two values. They returns boolean value.
Examples are,
== ($a==$b returns true if $a is equal to $b)
=== ($a===$b returns true if $a is equal to $b and $a has the same datatype as of $b)
!= or <> ( $a!=$b or $a<>$b will return true if $a is not equal to $b)
!==($ a!== $b will return true if $a is not equal to $b, or they are not of the same type.
< ($a < $b will return true if $a is less than $b.) > ($a > $b will return true if $a is strictly greater than $b.)
<= ($a <= $b will return true if $a is less than or equal to $b.) >= ($a >= $b will return true if $a is greater than or equal to $b.
5) Error Control Operators: The @ (at sign) is error control operator in php. If @ is prepend to variables, function, include() calls, constants then any error messages that might be generated by that expression will be ignored.
If the track_errors feature is enabled- which can be enabled by setting TRACK_ERRORS, any error message generated by the expression will be saved in the variable $php_errormsg. This variable will be overwritten on each error occurs.
6) Execution Operators: With php OS command can by executed by execution operator. If the commands are within backticks (` `) then PHP will attempt to execute the contents of the backticks as a shell command. Example is echo `ls -l`.
The backtick operator is disabled when safe mode (safe_mode =ON) is enabled or shell_exec() is disabled.
7) Incrementing/Decrementing Operators: Four incremental/decremental operators there.
++$a : Increments $a by one, then returns $a.
$a++ : Returns $a, then increments $a by one.
--$a : Decrements $a by one, then returns $a.
$a-- : Returns $a, then decrements $a by one.
8) Logical Operators:
AND : $a and $b becomes TRUE if both $a and $b are TRUE.
OR : $a or $b becomes TRUE if either $a or $b is TRUE.
XOR : $a xor $b becomes TRUE if either $a or $b is TRUE, but not both.
! : ! $a becomes TRUE if $a is not TRUE.
&& : $a && $b becomes TRUE if both $a and $b are TRUE.
|| : $a || $b becomes TRUE if either $a or $b is TRUE.
9) String Operators: One string type operation is concatenation(.) operator that concatenate it's left and right arguments. Another one is concatenating assignment operator ('.='), which appends the argument on the right side to the argument on the left side.
10) Array Operators: They work on array and examples are +,==,===, !=, <>,!== .
11) Type Operators: Example is, instanceof - which can be used to determine whether a variable is an instantiated object of a class.
| Reactions: |
Thursday, March 19, 2009
Magic constants in php
In php there are many predefined constants. Normal constant value is not changed but out of the many predefined constants seven constants value are changed based on the usage inside the script. These seven constants are called magic constants.
Their description are as below.
1)__LINE__ : This constant prints the current line number of the file.
2)__FILE__ : __FILE__ prints the absolute path of the file. If it is used inside an include, the name of the included file is returned.
3)__DIR__ : It prints the directory name of the file. If used inside an include, the directory of the included file is returned. Note that trailing slash is not there without unix root (/) directory.
4)__FUNCTION__ : It returns the function name. In PHP 5 it is case sensitive but in PHP version 4 its value was always lowercased.
5)__CLASS__ : It returns the class name. In PHP 5 it is case sensitive but in PHP version 4 its value was always lowercased.
6)__METHOD__ : It prints the class method name.
7)__NAMESPACE__ : It returns the name of the current namespace (case-sensitive). This constant is defined in compile-time (Added in PHP 5.3.0).
Code
Output
This example will show about magic constants.
This is line number: 6
This is file name: C:\apache2triad\htdocs\magic_constants.php
A function called -MyBaseClass
A function called --MyDerivedClass
B function called -MyDerivedClass
B function called --MyDerivedClass
This is a function: function_b
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Constants in php
Their description are as below.
1)__LINE__ : This constant prints the current line number of the file.
2)__FILE__ : __FILE__ prints the absolute path of the file. If it is used inside an include, the name of the included file is returned.
3)__DIR__ : It prints the directory name of the file. If used inside an include, the directory of the included file is returned. Note that trailing slash is not there without unix root (/) directory.
4)__FUNCTION__ : It returns the function name. In PHP 5 it is case sensitive but in PHP version 4 its value was always lowercased.
5)__CLASS__ : It returns the class name. In PHP 5 it is case sensitive but in PHP version 4 its value was always lowercased.
6)__METHOD__ : It prints the class method name.
7)__NAMESPACE__ : It returns the name of the current namespace (case-sensitive). This constant is defined in compile-time (Added in PHP 5.3.0).
Code
<html>
<body>
<?php
echo "This example will show about magic constants." ;
echo "<br />";
echo "This is line number: ". __LINE__;
echo "<br />";
echo "This is file name: ". __FILE__;
echo "<br />";
class MyBaseClass
{
function function_a()
{
echo "A function called -" . __CLASS__ . "<br/>";
}
function function_b()
{
echo "B function called -" . get_class($this) . "<br/>";
}
}
class MyDerivedClass extends MyBaseClass
{
function function_a()
{
parent::function_a();
echo "A function called --" . __CLASS__ . "<br/>";
}
function function_b()
{
parent::function_b();
echo "B function called --" . get_class($this) . "<br/>";
echo "This is a function: " .__FUNCTION__ ."<br/ >";
}
}
$object_b = new MyDerivedClass();
$object_b->function_a();
echo "<br/>";
$object_b->function_b();
echo "<br />";
echo "<br />";
?>
</body>
</html>
Output
This example will show about magic constants.
This is line number: 6
This is file name: C:\apache2triad\htdocs\magic_constants.php
A function called -MyBaseClass
A function called --MyDerivedClass
B function called -MyDerivedClass
B function called --MyDerivedClass
This is a function: function_b
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Constants in php
| Reactions: |
Wednesday, March 18, 2009
Constants in php
- Constant can be defined by using the define() function or by using the const keyword outside the class definition as of php 5.3.0.
- Constant is different from variables in php. To access variable you must use $ prepend but to access constant you should not prepend with a $. With function constant() constant value can also be retrieved.
- Constants can't be redefined or undefined once they have been set.
- Unlike variables constants value is not locale. You can access from anywhere within the script.
- A simple example is below.
<?php
define("myCONSTANT", "This is a constant.");
echo myCONSTANT;
?>
which will print output,
This is a constant.
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Magic constants in php
| Reactions: |
Working with cookie in php(set, retrieve, delete)
Cookies are the mechanism for storing data in the browser machine and thus tracking the user. With php you can set, retrieve and delete cookies.
Set Cookie:
With the setcookie() function you can send cookie to the browser. The syntax of this function is,
bool setcookie(name, value, expire, path, domain, secure, httponly);
where name is the name that you name the cookie.
value is the information that to be stored in the browser's computer.
expire defines the time the cookie expires.
path term is related to server which indicates the domain that the cookie will be available for. If you set to '/', the cookie will be available within the entire domain. The default value is the current directory that the cookie is being set in.
domain sets whether cookie will be available to subdomain. If you set ".test.com" /"test.com" then in all subdomains of test.com cookie will be available. If you set "mail.mytest.test.com" then the cookie will be available under mail.mytest.test.com subdomain.
secure - which is set to FALSE by default. If it is set then cookie will be only transmitted if it get HTTPS secure connection.
httponly - If it is set to true cookie will only be accessible for http connection. For scripting language cookie will not be available.
setcookie() function must be placed on the script prior to any output. So it means before <html> tags as well as any whitespaces.
Following is a declaration of a cookie which specifies cookie name will be myCookie, value to be assigned is "Abdul Momin Arju" and after 1 hours cookie should be expired.
<?php
setcookie("myCookie", "Abdul Momin Arju", time()+3600);
?>
The value of the cookie is automatically URLencoded when sending the cookie, and automatically decoded when received. In order to prevent URLencoding, use setrawcookie() function.
Retrieve a Cookie value
Cookie can be accessed by variables $_COOKIE or $_REQUEST or $HTTP_COOKIE_VARS arrays.
Delete a cookie:
When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.
Example:
<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
?>
The following is an example of set cookie value and displaying on cookie info in the browser.
<?php
$value = 'My Cookie Value';
setcookie("myCookie", $value, time()+3600);
?>
<?php
// Print individual cookie
echo $_COOKIE["myCookie"];
echo $HTTP_COOKIE_VARS["myCookie"];
//print_r($_COOKIE); --For debugging
?>
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Constants in php
Magic constants in php
Set Cookie:
With the setcookie() function you can send cookie to the browser. The syntax of this function is,
bool setcookie(name, value, expire, path, domain, secure, httponly);
where name is the name that you name the cookie.
value is the information that to be stored in the browser's computer.
expire defines the time the cookie expires.
path term is related to server which indicates the domain that the cookie will be available for. If you set to '/', the cookie will be available within the entire domain. The default value is the current directory that the cookie is being set in.
domain sets whether cookie will be available to subdomain. If you set ".test.com" /"test.com" then in all subdomains of test.com cookie will be available. If you set "mail.mytest.test.com" then the cookie will be available under mail.mytest.test.com subdomain.
secure - which is set to FALSE by default. If it is set then cookie will be only transmitted if it get HTTPS secure connection.
httponly - If it is set to true cookie will only be accessible for http connection. For scripting language cookie will not be available.
setcookie() function must be placed on the script prior to any output. So it means before <html> tags as well as any whitespaces.
Following is a declaration of a cookie which specifies cookie name will be myCookie, value to be assigned is "Abdul Momin Arju" and after 1 hours cookie should be expired.
<?php
setcookie("myCookie", "Abdul Momin Arju", time()+3600);
?>
The value of the cookie is automatically URLencoded when sending the cookie, and automatically decoded when received. In order to prevent URLencoding, use setrawcookie() function.
Retrieve a Cookie value
Cookie can be accessed by variables $_COOKIE or $_REQUEST or $HTTP_COOKIE_VARS arrays.
Delete a cookie:
When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.
Example:
<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
?>
The following is an example of set cookie value and displaying on cookie info in the browser.
<?php
$value = 'My Cookie Value';
setcookie("myCookie", $value, time()+3600);
?>
<?php
// Print individual cookie
echo $_COOKIE["myCookie"];
echo $HTTP_COOKIE_VARS["myCookie"];
//print_r($_COOKIE); --For debugging
?>
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Constants in php
Magic constants in php
| Reactions: |
Accessing data from html forms in php
Whenever a form is submitted to php, the information from the form is automatically available to php. Php then process the information of the form.
There are several ways to access the html form data into php.
1)Using $_GET, $_POST and $_REQUEST variable:
The $_GET variable is used to collect values from a form with method="get" .
When using the $_GET variable all variable names and values are displayed in the URL.
With GET method in form maximum 100 characters can be send.
The $_GET method is useful for bookmark.
The $_POST variable is used to collect values from a form with method="post". In the url the values are not shown, so this method would be used to pass sensitive information to the server.
The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.
The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
2)Using $HTTP_POST_VARS variable. But it would be used because this variable may be disabled.
3)By setting the PHP directive register_globals to ON. From PHP 4.2.0 and onwards this variable default value is changed from ON to OFF. This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. So don't rely on this feature.
Below is the simple html form. Whenever you click submit button process_form.php will be called.
Here is the process_form.php code.
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Constants in php
Magic constants in php
There are several ways to access the html form data into php.
1)Using $_GET, $_POST and $_REQUEST variable:
The $_GET variable is used to collect values from a form with method="get" .
When using the $_GET variable all variable names and values are displayed in the URL.
With GET method in form maximum 100 characters can be send.
The $_GET method is useful for bookmark.
The $_POST variable is used to collect values from a form with method="post". In the url the values are not shown, so this method would be used to pass sensitive information to the server.
The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.
The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
2)Using $HTTP_POST_VARS variable. But it would be used because this variable may be disabled.
3)By setting the PHP directive register_globals to ON. From PHP 4.2.0 and onwards this variable default value is changed from ON to OFF. This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. So don't rely on this feature.
Below is the simple html form. Whenever you click submit button process_form.php will be called.
<html>
<title>Simple Testing of Reading forms</title>
<body>
<form action="process_form.php" method="post">
Your Name: <input type="text" name="name"><br />
Age: <input type="text" name="age"><br />
Class: <select name="Classes">
<option value="6">Six</option>
<option value="7">Seven</option>
<option value="8">Eight</option>
<option value="9">Nine</option>
<option value="10">Ten</option>
</select> <br />
<input type="submit" value="submit" name="submit">
</form>
</body>
</html>
Here is the process_form.php code.
<html>
<body>
<?php
echo "Your name is" . $_POST["name"] . " and you are". $_POST["age"] ." years old.
You read in class ". $_POST["Classes"];
?>
</body>
</html>
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Constants in php
Magic constants in php
| Reactions: |
Tuesday, March 17, 2009
Running perl fails perl lib version doesn't match executable version
Problem Description
Whenever you wish to use perl it did not run failing with perl lib version doesn't match executable version. Even it happens whenever you wish to know the version of the perl as shown below.
C:\>perl.exe -V
Perl lib version (v5.8.3) doesn't match executable version (v5.8.7) at E:\oracle\product\10.2.0\db_1\perl\5.8.3\lib/MSWin32-x86-multi-thread/Config.pm line 32.
Compilation failed in require.
BEGIN failed--compilation aborted.
Cause and Solution of the Problem:
As the error indicates executable version of perl(perl.exe) does not match it library version which is under MSWin32-x86-multi-thread/Config.pm. This is a possible problem if you install perl two times that have different version in your hand. Note that many software includes perl software. So if you install other software then perl can be integrated with it. If you have oracle database then already perl is there. If you install any web (server+ php) then perl may be integrated with the installation.
The solution is use the same perl executable version as of library version. Suppose if I select executable version of 5.8.3 then it will solve my problem.
C:\>E:\oracle\product\10.2.0\db_1\perl\5.8.3\bin\MSWin32-x86-multi-thread\perl.exe -V
Summary of my perl5 (revision 5 version 8 subversion 3) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
Whenever you wish to use perl it did not run failing with perl lib version doesn't match executable version. Even it happens whenever you wish to know the version of the perl as shown below.
C:\>perl.exe -V
Perl lib version (v5.8.3) doesn't match executable version (v5.8.7) at E:\oracle\product\10.2.0\db_1\perl\5.8.3\lib/MSWin32-x86-multi-thread/Config.pm line 32.
Compilation failed in require.
BEGIN failed--compilation aborted.
Cause and Solution of the Problem:
As the error indicates executable version of perl(perl.exe) does not match it library version which is under MSWin32-x86-multi-thread/Config.pm. This is a possible problem if you install perl two times that have different version in your hand. Note that many software includes perl software. So if you install other software then perl can be integrated with it. If you have oracle database then already perl is there. If you install any web (server+ php) then perl may be integrated with the installation.
The solution is use the same perl executable version as of library version. Suppose if I select executable version of 5.8.3 then it will solve my problem.
C:\>E:\oracle\product\10.2.0\db_1\perl\5.8.3\bin\MSWin32-x86-multi-thread\perl.exe -V
Summary of my perl5 (revision 5 version 8 subversion 3) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
| Reactions: |
Track error messages on php
It is common in php that you write codes but whenever you tried to display on the web browser it displays nothing even a html. You want to know the behind where actually problem occurs. In which line or in which part of the code. The error_reporting function will help in this case really well.
Below is an example which is written to display directory contents inside c:\Documents and Settings folder but at the end on the browser it displayed nothing. You by enabling error reporting I might wish the say what actually happening there.
Code
Output
Based on the output you are aware that there is problem with variable naming. As variable is case-sensitive in php so you can write the code as,
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Magic constants in php
Below is an example which is written to display directory contents inside c:\Documents and Settings folder but at the end on the browser it displayed nothing. You by enabling error reporting I might wish the say what actually happening there.
Code
<html>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('html_errors', true);
$fileHandler = opendir('C:\Documents and Settings');
while (false !== ($file = readdir($filehandler))) {
$files[] = $file;
}
sort($files);
print_r($files);
closedir($filehandler);
?>
</body>
</html>
Output
Notice: Undefined variable: filehandler in C:\apache2triad\htdocs\array_file.php
on line 8
Warning: readdir(): supplied argument is not a valid Directory resource in
C:\apache2triad\htdocs\array_file.php on line 8
Warning: sort() expects parameter 1 to be array, null given in
C:\apache2triad\htdocs\array_file.php on line 11
Notice: Undefined variable: filehandler in C:\apache2triad\htdocs\array_file.php
on line 13
Warning: closedir(): supplied argument is not a valid Directory resource in
C:\apache2triad\htdocs\array_file.php on line 13
Based on the output you are aware that there is problem with variable naming. As variable is case-sensitive in php so you can write the code as,
Related Documents
<html>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('html_errors', true);
$fileHandler = opendir('C:\Documents and Settings');
while (false !== ($file = readdir($fileHandler))) {
$files[] = $file;
}
sort($files);
print_r($files);
closedir($fileHandler);
?>
</body>
</html>
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Magic constants in php
| Reactions: |
List of directory contents using array in php
Code
<html>
<body>
<?php
$fileHandler = opendir('C:\Documents and Settings');
while (false !== ($file = readdir($fileHandler))) {
$files[] = $file;
}
sort($files);
print_r($files);
closedir($fileHandler);
?>
</body>
</html>
Output
Array ( [0] => . [1] => .. [2] => A [3] => Administrator [4] => All Users [5] => Default User [6] => LocalService [7] => NetworkService [8] => apache2triad )
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Magic constants in php
<html>
<body>
<?php
$fileHandler = opendir('C:\Documents and Settings');
while (false !== ($file = readdir($fileHandler))) {
$files[] = $file;
}
sort($files);
print_r($files);
closedir($fileHandler);
?>
</body>
</html>
Output
Array ( [0] => . [1] => .. [2] => A [3] => Administrator [4] => All Users [5] => Default User [6] => LocalService [7] => NetworkService [8] => apache2triad )
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Array declaration, assignment and printing in php
Variables in PHP
Magic constants in php
| Reactions: |
Monday, March 16, 2009
Array declaration, assignment and printing in php
The term array comes in order to store multiple values in a single variable. In php with help of Array you can store multiple values in a single variable instead of defines multiple variables.
Each element in the array is accessed by the associated key value. A key may be either an integer or a string. By default if no key value is mentioned then it starts with 0.
Array declaration Syntax:
An array is created by the array()language construct.
Like,
$arrayName=array('Arju', 'Momin', 'Robert', 'Davis');
Here array key value is omitted. If array key value is omitted then first element is accessed by $variable_name[interger_key_value_start_from_0]
In this case $arrayName[0] have value Arju.
$arrayName[1] have the value Momin and so on.
Example 01:
The following is the php code,
Output
This is first element :Arju
This is second element :Momin
Example 02:
Below is an example where key value is assigned manually.
If a key is not specified for a value, the maximum of the integer indices is taken and the new key will be that value plus 1.
Output
Example 03:
You can define multidimensional array by declaring array within an array.
Following is an example.
Output
Result of Roll number of 11 of class Eight is: 89
Result of Roll number of 127 of class Nine is: 56
Modifying Array Values
In order to set an array just issue,
$arrayName[key_value]=new_value;
If the variable does not exist array will be created. So it is an another way to create array.
In order to remove element from the array issue,
unset ($arrayName[key_value]);
In order to the array itself issue,
unset $arrayname;
In order to delete array element one by one issue,
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Variables in PHP
Magic constants in php
Each element in the array is accessed by the associated key value. A key may be either an integer or a string. By default if no key value is mentioned then it starts with 0.
Array declaration Syntax:
An array is created by the array()language construct.
Like,
$arrayName=array('Arju', 'Momin', 'Robert', 'Davis');
Here array key value is omitted. If array key value is omitted then first element is accessed by $variable_name[interger_key_value_start_from_0]
In this case $arrayName[0] have value Arju.
$arrayName[1] have the value Momin and so on.
Example 01:
The following is the php code,
<html>
<body>
<?php
$arrayName= array("Arju","Momin","Robert","Davis");
echo "This is first element :" . $arrayName[0];
echo "<br />";
echo "This is second element :" . $arrayName[1];
?>
</body>
</html>
Output
This is first element :Arju
This is second element :Momin
Example 02:
Below is an example where key value is assigned manually.
If a key is not specified for a value, the maximum of the integer indices is taken and the new key will be that value plus 1.
<html>
<body>
<?php
$arrayName["students"]= 48;
$arrayName[10]=100;
$arrayName[]=120; //120 assigned to key value 11 as maximum key is 10, so it is 10+1
echo "Total Students :" . $arrayName["students"];
echo "<br />";
echo "10th positioned student mark :" . $arrayName[10];
echo "<br />";
echo "11th positioned student mark :" . $arrayName[11];
?>
</body>
</html>
Output
Total Students :48
10th positioned student mark :100
11th positioned student mark :120
Example 03:
You can define multidimensional array by declaring array within an array.
Following is an example.
<html>
<body>
<?php
$student=Array
(
"Seven" => Array
(1 => 76 ,2 => 65 , 3 => 45 ),
"Eight" => Array
(10 => 87 , 89 ),
"Nine" => Array
( 23 => 98, 25 => 86 , 27 => 56 )
) ;
echo "Result of Roll number of 11 of class Eight is: " .$student['Eight'][11];
echo "<br />";
echo "Result of Roll number of 127 of class Nine is: " .$student['Nine'][27];
?>
</body>
</html>
Output
Result of Roll number of 11 of class Eight is: 89
Result of Roll number of 127 of class Nine is: 56
Modifying Array Values
In order to set an array just issue,
$arrayName[key_value]=new_value;
If the variable does not exist array will be created. So it is an another way to create array.
In order to remove element from the array issue,
unset ($arrayName[key_value]);
In order to the array itself issue,
unset $arrayname;
Example:
<?php
$arr = array(1,5);
$arr[] = 8; // This is the same as $arr[2] = 8;
print_r($arr);
$arr["x"] = 42; // Adds a new element to array.
unset($arr[1]); // Removes 2nd element from the array that is 5.
print_r($arr);
unset($arr); // Deletes whole element of the array
print_r($arr);
?>
In order to delete array element one by one issue,
foreach ($arr as $i => $value) {
unset($arr[$i]);
}
Related Documents
Working with cookie in php(set, retrieve, delete)
Accessing data from html forms in php
Track error messages on php
Variables in PHP
Magic constants in php
| Reactions: |
Integer and floating point number in Php
Integers in php can be declared as decimal, octal or hexadecimal.
To declare an octal precede the number with zero. (0)
To declare an hexadecimal precede the number with 0x.
The following is the declaration of integer types.
The Integer size can be determined using the constant PHP_INT_SIZE.
The maximum size of the Integer can be determined using the constant PHP_INT_MAX.
The maximum value of Integer is platform dependent.
If Php encounters a value that is beyond integer type then it treats the value as float.
Some declaration of floating point numbers are,
Related Documents
Datatypes in Php
Variables in PHP
Magic constants in php
Boolean datatype in Php
To declare an octal precede the number with zero. (0)
To declare an hexadecimal precede the number with 0x.
The following is the declaration of integer types.
The Integer size can be determined using the constant PHP_INT_SIZE.
The maximum size of the Integer can be determined using the constant PHP_INT_MAX.
The maximum value of Integer is platform dependent.
If Php encounters a value that is beyond integer type then it treats the value as float.
Some declaration of floating point numbers are,
Related Documents
Datatypes in Php
Variables in PHP
Magic constants in php
Boolean datatype in Php
| Reactions: |
Boolean datatype in Php
The boolean datatype in php in considered specially. The boolean datatype expresses the truth value which can be either TRUE or FALSE.
Confusion may come while your print boolean datatype and while converting the value of boolean datatype variable.
When converting to boolean type the following values are considered as FALSE.
1)the boolean FALSE itself
2)the integer 0 (zero)
3)the float 0.0 (zero)
4)the empty string, and the string "0"
5)an array with zero elements
6)an object with zero member variables (PHP 4 only)
7)the special type NULL (including unset variables)
8)SimpleXML objects created from empty tags
Except the above 8 types all converted boolean type are considered as TRUE even a -1.
Whenever you print any boolean FALSE value it will print NULL and whenever you print any boolean TRUE value it will print 1 but never think that FALSE is NULL and 1 is a constant for TRUE. NULL is boolean value that indicates FALSE and 1 is a boolean value that indicates TRUE.
Symbolic constants are specifically designed to always and only reference their constant value. But booleans are not symbolic constants, they are values which means either true or false. So operate them like symbolic constants may have problems. Like (true+true) will print 2 but two boolean variable containing truth value TRUE adding will print 1.
<html>
<body>
<?php
$booleanTType=True;
$booleanFType=False;
echo 'Output of "(True)":'.$booleanTType ;
echo "<br />";
echo 'Output of "(False)":'. $booleanFType ;
echo "<br />";
echo (true+true);
echo "<br />";
echo 'Output of "(True+True)":'.($booleanTType+$booleanTTypes);
echo "<br />";
echo 'Output of "(False+False)":'.($booleanFType+$booleanFTypes) ;
?>
</body>
</html>
Output
Output of "(True)":1
Output of "(False)":
2
Output of "(True+True)":1
Output of "(False+False)":0
Related Documents
Datatypes in Php
Integer and floating point number in Php
Variables in PHP
Magic constants in php
Confusion may come while your print boolean datatype and while converting the value of boolean datatype variable.
When converting to boolean type the following values are considered as FALSE.
1)the boolean FALSE itself
2)the integer 0 (zero)
3)the float 0.0 (zero)
4)the empty string, and the string "0"
5)an array with zero elements
6)an object with zero member variables (PHP 4 only)
7)the special type NULL (including unset variables)
8)SimpleXML objects created from empty tags
Except the above 8 types all converted boolean type are considered as TRUE even a -1.
Whenever you print any boolean FALSE value it will print NULL and whenever you print any boolean TRUE value it will print 1 but never think that FALSE is NULL and 1 is a constant for TRUE. NULL is boolean value that indicates FALSE and 1 is a boolean value that indicates TRUE.
Symbolic constants are specifically designed to always and only reference their constant value. But booleans are not symbolic constants, they are values which means either true or false. So operate them like symbolic constants may have problems. Like (true+true) will print 2 but two boolean variable containing truth value TRUE adding will print 1.
<html>
<body>
<?php
$booleanTType=True;
$booleanFType=False;
echo 'Output of "(True)":'.$booleanTType ;
echo "<br />";
echo 'Output of "(False)":'. $booleanFType ;
echo "<br />";
echo (true+true);
echo "<br />";
echo 'Output of "(True+True)":'.($booleanTType+$booleanTTypes);
echo "<br />";
echo 'Output of "(False+False)":'.($booleanFType+$booleanFTypes) ;
?>
</body>
</html>
Output
Output of "(True)":1
Output of "(False)":
2
Output of "(True+True)":1
Output of "(False+False)":0
Related Documents
Datatypes in Php
Integer and floating point number in Php
Variables in PHP
Magic constants in php
| Reactions: |
Datatypes in Php
In Php you don't need to declare datatype of the variable. Based on the variable assignment value php automatically converts it to corresponding datatype. In php there is eight different datatypes.
A)Four Scalar Types:
1)Integer
2)Float/Double
3)String
4)Boolean
B)Two compound Types:
1)Array
2)Object
C)Two special types:
1)Resource
2)Null
The type of variable is decided at runtime by PHP depending on the context in which that variable is used.
For String type checking the function is is_string()
To convert to boolean type use the (bool) or (boolean) casts.
To convert to string type use the (string) cast or the strval() function. Though string conversion is done automatically.
A boolean TRUE value is converted to the string "1" and boolean FALSE is converted to "" (the empty string) and vice-versa.
Below is an example:
And the output is,
Note that boolean TRUE or FALSE is treated differently in Php. If you display boolean FALSE expression, NULL will be printed and if you display boolean TRUE expression, 1 will be printed.
Related Documents
Integer and floating point number in Php
Variables in PHP
Magic constants in php
Boolean datatype in Php
A)Four Scalar Types:
1)Integer
2)Float/Double
3)String
4)Boolean
B)Two compound Types:
1)Array
2)Object
C)Two special types:
1)Resource
2)Null
The type of variable is decided at runtime by PHP depending on the context in which that variable is used.
- With var_dump() function you can check the type and value of an expression.
- With the gettype() function you can also get the type of the variable.
- With is_{type}() function you can check a certain type. The {type} within brace means that type should be replaced by any data type.
For String type checking the function is is_string()
- To convert a variable from one type to another either use cast or use the settype() function.
To convert to boolean type use the (bool) or (boolean) casts.
To convert to string type use the (string) cast or the strval() function. Though string conversion is done automatically.
A boolean TRUE value is converted to the string "1" and boolean FALSE is converted to "" (the empty string) and vice-versa.
Below is an example:
<html>
<body>
<?php
$btype=FALSE;
$itype=10;
$ftype=100.1;
$stype="This is a String datatype.";
echo gettype($btype);
echo " ". (boolean)($btype); //Note that the display behaviour of boolean type is
either null or 1.
echo "<br />";
echo gettype($itype);
echo " ".$itype;
echo "<br />";
echo gettype($ftype);
echo " ".$ftype;
echo "<br />";
echo gettype($stype);
echo " ". $stype;
echo "<br />";
?>
</body>
</html>
And the output is,
boolean
integer 10
double 100.1
string This is a String datatype.
Note that boolean TRUE or FALSE is treated differently in Php. If you display boolean FALSE expression, NULL will be printed and if you display boolean TRUE expression, 1 will be printed.
Related Documents
Integer and floating point number in Php
Variables in PHP
Magic constants in php
Boolean datatype in Php
| Reactions: |
Oracle datatype internal code representation
As it is shown in How can one dump/ examine the exact content of a database column? every datatype in oracle has its internal code. In this example every oracle datatype along with their corresponding internal code is shown.
http://arjudba.blogspot.com/2009/12/oracle-object-type-exercises-varray.html
http://arjudba.blogspot.com/2009/12/practice-oracle-joins-examples.html
http://arjudba.blogspot.com/2009/12/oracle-security-practices.html
http://arjudba.blogspot.com/2009/12/exercises-with-oracle-create-table-add.html
http://arjudba.blogspot.com/2009/12/oracle-database-creation-exercises.html
http://arjudba.blogspot.com/2009/12/basic-oracle-sql-exercise.html
http://arjudba.blogspot.com/2009/08/format-model-modifiers-fx-and-fm.html
http://arjudba.blogspot.com/2009/08/number-format-models-in-oracle.html
http://arjudba.blogspot.com/2009/08/format-models-in-oracle.html
http://arjudba.blogspot.com/2009/07/sql-decode.html
http://arjudba.blogspot.com/2009/07/how-to-know-row-of-table-belong-to.html
http://arjudba.blogspot.com/2009/06/how-to-know-which-objects-are-being.html
http://arjudba.blogspot.com/2009/06/ddl-with-wait-option-in-11g.html
http://arjudba.blogspot.com/2009/06/ora-00939-too-many-arguments-when-case.html
http://arjudba.blogspot.com/2009/03/oracle-datatype-internal-code.html
http://arjudba.blogspot.com/2009/03/how-to-know-list-of-constraints-and.html
http://arjudba.blogspot.com/2009/02/how-to-know-dependent-objectswhich.html
http://arjudba.blogspot.com/2009/02/how-to-search-stringkey-value-from.html
http://arjudba.blogspot.com/2009/02/how-to-know-when-tableobjects-ddlcode.html
http://arjudba.blogspot.com/2009/02/ora-00920-invalid-relational-operator.html
http://arjudba.blogspot.com/2009/01/adding-default-value-to-column-on-table.html
http://arjudba.blogspot.com/2009/01/ora-12838-cannot-readmodify-object.html
http://arjudba.blogspot.com/2009/01/ora-01779-cannot-modify-column-which.html
http://arjudba.blogspot.com/2009/01/updating-table-based-on-another-table.html
http://arjudba.blogspot.com/2009/01/ora-00054-resource-busy-and-acquire.html
http://arjudba.blogspot.com/2008/12/troubleshoot-ora-02292-ora-02449-and.html
Datatype Code -------------------------------------- ------- 1. VARCHAR2(size [BYTE | CHAR]) 01 2. NVARCHAR2(size) 01 3. NUMBER[(precision [, scale]]) 02 4. LONG 08 5. DATE 12 6. BINARY_FLOAT 21 7. BINARY_DOUBLE 22 8. RAW(size) 23 9. LONG RAW 24 10.ROWID 69 11.CHAR [(size [BYTE | CHAR])] 96 12.NCHAR[(size)] 96 13.CLOB 112 14.NCLOB 112 15.BLOB 113 16.BFILE 114 17.TIMESTAMP [(fractional_seconds)] 180 18.TIMESTAMP [(fractional_seconds)] WITH TIME ZONE 181 19.INTERVAL YEAR [(year_precision)] TO MONTH 182 20.INTERVAL DAY [(day_precision)] TO SECOND [(fractional_seconds)] 183 21.UROWID [(size)] 208 22.TIMESTAMP [(fractional_seconds)] WITH LOCAL TIME ZONE 231Related Documents
http://arjudba.blogspot.com/2009/12/oracle-object-type-exercises-varray.html
http://arjudba.blogspot.com/2009/12/practice-oracle-joins-examples.html
http://arjudba.blogspot.com/2009/12/oracle-security-practices.html
http://arjudba.blogspot.com/2009/12/exercises-with-oracle-create-table-add.html
http://arjudba.blogspot.com/2009/12/oracle-database-creation-exercises.html
http://arjudba.blogspot.com/2009/12/basic-oracle-sql-exercise.html
http://arjudba.blogspot.com/2009/08/format-model-modifiers-fx-and-fm.html
http://arjudba.blogspot.com/2009/08/number-format-models-in-oracle.html
http://arjudba.blogspot.com/2009/08/format-models-in-oracle.html
http://arjudba.blogspot.com/2009/07/sql-decode.html
http://arjudba.blogspot.com/2009/07/how-to-know-row-of-table-belong-to.html
http://arjudba.blogspot.com/2009/06/how-to-know-which-objects-are-being.html
http://arjudba.blogspot.com/2009/06/ddl-with-wait-option-in-11g.html
http://arjudba.blogspot.com/2009/06/ora-00939-too-many-arguments-when-case.html
http://arjudba.blogspot.com/2009/03/oracle-datatype-internal-code.html
http://arjudba.blogspot.com/2009/03/how-to-know-list-of-constraints-and.html
http://arjudba.blogspot.com/2009/02/how-to-know-dependent-objectswhich.html
http://arjudba.blogspot.com/2009/02/how-to-search-stringkey-value-from.html
http://arjudba.blogspot.com/2009/02/how-to-know-when-tableobjects-ddlcode.html
http://arjudba.blogspot.com/2009/02/ora-00920-invalid-relational-operator.html
http://arjudba.blogspot.com/2009/01/adding-default-value-to-column-on-table.html
http://arjudba.blogspot.com/2009/01/ora-12838-cannot-readmodify-object.html
http://arjudba.blogspot.com/2009/01/ora-01779-cannot-modify-column-which.html
http://arjudba.blogspot.com/2009/01/updating-table-based-on-another-table.html
http://arjudba.blogspot.com/2009/01/ora-00054-resource-busy-and-acquire.html
http://arjudba.blogspot.com/2008/12/troubleshoot-ora-02292-ora-02449-and.html
| Reactions: |
Sunday, March 15, 2009
Variables in PHP
In any programming language variables are the declaration which stands for value. In PHP, variables can be declared to store numbers, characters or any values. Variables can be used as many as you wish inside the script.
Following is an example of PHP variables using and displaying the value of the variables.
The following is the output.
Note that, in the case of "assign by reference" the value of the variable is change if reference value is changed but in case of "assign by expression" if source changes has no effect on assigned variable.
Related Documents
Datatypes in Php
Integer and floating point number in Php
Magic constants in php
Boolean datatype in Php
- In PHP all variables must start with $ sign. But we don't need to declare the data type of the variables. PHP automatically converts the variable to the correct data type, depending on how they are set. That's why PHP is called loosely typed language.
- The variable name in PHP is case-sensitive.
- A variable name must start with a letter or an underscore "_"
- A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, _ and the bytes from 127 through 255 (0x7f-0xff). )
- It should not contain spaces.
- $this is a special variable that can't be assigned. By default, variables are always assigned by value. Note that PHP offers assignment of values to the variable by two ways, 1) Assign by expression. 2) Assign by reference (simply prepend an ampersand (&) to the beginning of the variable which is being assigned).
Following is an example of PHP variables using and displaying the value of the variables.
<html>
<body>
<?php
$variable1='This is string type variable';
$_variable2=100;
echo $variable1 . "<br />";
echo $_variable2. "<br />";
$variable3=&$_variable2;
$variable4=$_variable2;
echo "Variable3 value:" . $variable3 . "<br />";
echo "variable4 value:" . $variable4. "<br />";
$_variable2=200;
echo "After assignment to _variable2 Variable3 value:" . $variable3. "<br />";
echo "After assignment to _variable2 variable4 value:" . $variable4;
?>
</body>
</html>
The following is the output.
This is string type variable
100
Variable3 value:100
variable4 value:100
After assignment to _variable2 Variable3 value:200
After assignment to _variable2 variable4 value:100
Note that, in the case of "assign by reference" the value of the variable is change if reference value is changed but in case of "assign by expression" if source changes has no effect on assigned variable.
Related Documents
Datatypes in Php
Integer and floating point number in Php
Magic constants in php
Boolean datatype in Php
| Reactions: |
Subscribe to:
Posts (Atom)
Tag Cloud
10.2g
10g
11g
11gR2
Abasa
About Oracle
Administration
Adsense
Alerts
Archival
ASM
ASP.Net
Audit
Audit Vault
Backup
Bangladesh
Block Corruption
Blogger
Browser
Bug
Business
Clone
Clusterware
Comments
Concepts
Connection
Controlfiles
Crime
CSS
Data Block
Data Dictionary
Data Guard
Data Mining
Data Pump
Data Type
Database Administration
Database Vault
DBConsole
Developer
Economics
EM
Excel
Exercise
Explain plan
Export
External Table
Facebook
Firefox
Firmware
Flashback
Forum
Functions
Games
Globalization Support
Grid Control
Hardware
History
HTML
IE
Import
Indexes
initializaion parameter
initialization parameter
Installation
Internals
Internet
Interview
isql*plus
Java
JavaScript
Job
Joins
Joke
Limitation
Linux
Listener
Logminer
Magento
Mail
Materialized View
Medical
Memory
Mobile
Money
Multimedia
MySQL
Net Services
Network
OCP
Operators
Oracle
Oracle Concepts
Oracle Recovery
OS
Others
OUI
Package
Packages
Parameters
Partitioning
Patchset
Performance
Perl
Pfile
Photos
PHP
PL/SQL
Profile
Pseudocolumns
Puzzle
Quiz
Quota
RAC
RAC Installation
Recovery
Recovery Problems
Redo Log
Reports
RMAN
Scripts
Security
SEO
Server Administration
SGA
Shell Script
Smarty
Social Marketing
Solaris
Spfile
SQL
SQL Tuning
SQL*Loader
Sql*Plus
Startup Problem
Streams
SwingBench
System Analysis
Tablespaces
Technology
Temp
TNS Error
Tools
Troubleshooting
Tuning
Undo
UNIX
Upgradation
Utilities
Version
Views
Vmware
Windows
Wordpress
XML