如何将PHP常量存储在MySQL数据库中
问题描述:
我需要以固定宽度格式创建一堆Feed,它们在布局上都相对相同,但它们都可以具有不同的格式。如何将PHP常量存储在MySQL数据库中
例如:
Field 1 can be 30 bytes wide, left justified and padded with 0s Field 2 can be 20 bytes wide, right justified padded with spaces
我想存储在数据库PHP的str_pad参数,但不知道存储pad_type参数的最佳方式,因为它是一个常数,我不能读回,如:
$field = str_pad($input, $width, $pad_string, $pad_type)
我想我可以换一个eval()
各地$pad_type
,但似乎粗略。
有没有更好的方法来做到这一点?
我卡着,PHP 5.0中,MySQL 4
在您的例子$ pad_type是一个变量,而不是一个常量。代码示例不完整? – six8
这是我在阅读问题后唯一能想到的事情:*什么?*我不知道你在做什么。你可以试着解释一下好吗? – ircmaxell
$ pad_type将是一个查询返回的变量,抱歉太过于模糊。 –