简体   繁体   English

在Drupal网站上的PHP代码中使用令牌

[英]Use token in php code on drupal site

I am using some tokens in my drupal site. 我在我的drupal网站上使用了一些令牌。

I have some php code where i need to use the token. 我有一些需要使用令牌的php代码。

print '[token]';

This works perfect but i need to use it in a function like 这工作完美,但我需要在类似的功能中使用它

myfunctionname('[token]') {
}

This doesn't work. 这行不通。 How can u use this token in php code without using the print function. 您如何在不使用打印功能的情况下在php代码中使用此令牌。 I am trying to encode the string wit a special function. 我正在尝试使用特殊功能对字符串进行编码。 So i must use the value from that token as parameter in the function. 因此,我必须使用该令牌中的值作为函数中的参数。

You could try the t() function like t('[token]') . 您可以尝试使用t()函数,例如t('[token]')

But it seems that token_replace() is the function you like to use. 但似乎token_replace()是您要使用的函数。

I solved the problem by adding some token on the simplenews tokens. 我通过在simplenews令牌上添加一些令牌来解决该问题。 Thanks for your help anyway. 还是要谢谢你的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM