在php中获取包含美元字符的PDO结果集

发布于 2025-01-07 11:07:13 字数 444 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风向决定发型 2025-01-14 11:07:13

它很可能不是美元字符,而是三角括号 (<>)。请参阅页面上的源代码以查看它们。

您可以使用 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. (< >)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文