在php中获取包含美元字符的PDO结果集
我有一个 postgres 表,其中有一列(称为 id),其中包含字符串。在大多数情况下,字符串包含美元字符,例如
。 我在 php 脚本中使用 PDO 语句来获取该表的相关行和列,包括上述 id 列。
但是当我尝试使用 id 列中的值时,此类 id 的 PDO 结果似乎为空。
Example:
Expected result: "id":"<sdfjkdsaf$test@com>", "body":"This is a test", ...
Real result: "id":"","body":"This is a test", ...
我猜原因是 php 将字符串中的美元字符解释为变量的开头。 是否有可能操纵 PDO 结果以便我可以使用包含 $ 的字符串?
I have a postgres table with a column (called id) which contains strings. In most cases the strings include a dollar character like <sdfjkdsaf$test@com>
.
I'm using PDO statements in a php script to fetch the relevant rows and columns of this table including the above described id-column.
But when I try to use the value from the id-column the PDO result for such an id seems to be empty.
Example:
Expected result: "id":"<sdfjkdsaf$test@com>", "body":"This is a test", ...
Real result: "id":"","body":"This is a test", ...
I guess the reason is that php interprets the dollar character in the string as the beginning of a variable.
Is there any possibility to manipulate the PDO result so that I can use strings containing $ ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它很可能不是美元字符,而是三角括号 (
<>
)。请参阅页面上的源代码以查看它们。您可以使用
htmlentities()
将其更改为 HTML 兼容版本。 (<代码><>)It's most likely not the dollar character, but the triangular brackets (
<>
). See the source code on your page to see them.You can use
htmlentities()
to change it into a HTML compliant version. (< >
)