aspose file tools*
The moose likes PHP and the fly likes PHP Data Types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "PHP Data Types" Watch "PHP Data Types" New topic
Author

PHP Data Types

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 319

They say PHP have buit-in data types like integer,string,float,boolean

but when i try to use it like

integer $a=10;
echo $a;
or
string $a="abc";
echo $a;

None of these works ,then how to use php built in data types





http://www.mahtabalam.net , Oracle Java Programmer , Oracle SQL Expert , Oracle Java Web Component Developer
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4490
    
    8

It has types, but it's a dynamically typed language. Which means that values have types, but the variables don't. So you don't declare the type of variables. So instead, you'd just do:

And notice that it's valid to do both of those: just because a variable has a numeric value doesn't mean you can't then assign it a string value.
Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 319

Thank you for answering the question.

I remember you very well, When i was preparing for my OCJP exam last year.I post a question and you answered it .
So you were the first one "Mathew Brown"

Thank you
timo corn
Ranch Hand

Joined: Oct 26, 2013
Posts: 68

btw you can get the Variable Type with gettype(). Results for the returned string taken from php.net:


"boolean"
"integer"
"double" (for historical reasons "double" is returned in case of a float, and not simply "float")
"string"
"array"
"object"
"resource"
"NULL"
"unknown type"


hth
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PHP Data Types