Reputation: 1661
What is the data type of image in PHP?
According to http://www.w3schools.com/php/php_datatypes.asp PHP supports the following data types:
So where does image fit in the above data types?
In my case the images are stored in database. In MySQL database they are stored in a table in a column whose data type is LONGBLOB. In SQL Server database they are stored in a table in a column whose data type is IMAGE.
Upvotes: 3
Views: 6806
Reputation: 406
The image in the database is most likely a path to the image, therefore you would need to use strings.
A string can be virtually anything. In your example a string would be something like this:
c:\images\image_path\1.png
or
//www.domain.com/path/to/image.png
Source: http://www.w3schools.com/php/php_string.asp
Upvotes: 0
Reputation: 146450
You'd have to use strings.
PHP strings do not necessarily have to contain plain text. For instance, the file_get_contents() function, which returns string
, can read binary files just fine.
In Details of the String Type we can read this:
The string in PHP is implemented as an array of bytes and an integer indicating the length of the buffer. It has no information about how those bytes translate to characters, leaving that task to the programmer. There are no limitations on the values the string can be composed of; in particular, bytes with value 0 (“NUL bytes”) are allowed anywhere in the string (however, a few functions, said in this manual not to be “binary safe”, may hand off the strings to libraries that ignore data after a NUL byte.)
This nature of the string type explains why there is no separate “byte” type in PHP – strings take this role. Functions that return no textual data – for instance, arbitrary data read from a network socket – will still return strings.
Upvotes: 6