Wednesday, 13 March 2013
Change Data Type Using Functions And Print Special Characters In Php
Data Type Conversion Using Functions In PHP :
There are some other ways to change the data type of available without using Type casting. There are some functions that change the data type of a variable .
For example
- intval (value) ;
- double (value);
It takes a value (whose data type we want to change ) as input and returns a double data type output .
- strval (value) ;
It takes a value (whose data type we want to change ) as input and returns a string data type output .
Print Special Characters In Php :
One thing I forgot in my previous post that we can use echo or print statement for printing output on screen. If you want to print a special character on screen like double quotes (") or single quote ( ' ) or backslash ( \ ), then we can print these by using a backslash . See the example to understand
<?php
echo "He said : \ " I love Pakistan \" ";
?>
Output
He said : "I love Pakistan "
In above statement you can see that I wanted to print double quotes on the screen so that I used backslash. If you want to print the name of the variable instead of its value then use single quotes in echo statement
<?php
$city = "Karachi";
echo 'City is : $city '. '<br/>;
echo " City is : $city ";
?>
Output
" Share With Others And Care Others "
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →
Related Posts:
PHP PHP Data types Programming Tricks and Tutorials Web Development
Subscribe to:
Post Comments (Atom)
0 comments: