gpt4 book ai didi

php - PHP中图像的数据类型是什么?

转载 作者:可可西里 更新时间:2023-11-01 07:56:14 25 4
gpt4 key购买 nike

PHP中图片的数据类型是什么?

根据 http://www.w3schools.com/php/php_datatypes.asp PHP 支持以下数据类型:

  • 字符串
  • 整数
  • Float( float - 也称为 double )
  • bool 值
  • 数组
  • 对象
  • 资源

那么image在上面的数据类型中适合哪里呢?

在我的例子中,图像存储在数据库中。在 MySQL 数据库中,它们存储在数据类型为 LONGBLOB 的列中的表中。在 SQL Server 数据库中,它们存储在数据类型为 IMAGE 的列中的表中。

最佳答案

你必须使用 strings .

PHP 字符串不一定必须包含纯文本。例如,file_get_contents()返回 string 的函数可以很好地读取二进制文件。

Details of the String Type我们可以读到:

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.

关于php - PHP中图像的数据类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27708652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com