开发者

Check if a variable has been set with the name of the value of another variable

开发者_StackOverflow中文版

I am setting up a template system, Long story short: I need/want to check if a variable with the name of a tag has been set. the tag name is in another variable.

Therefore, I need to check to see if the content of $tag (i.e. title) has a variable with the same name ($title).

Any help is appreciated. Thanks.


Use variable variables:

<?php

$tag = 'title';

// bool(false)
var_dump(isset($$tag));

$title = 'this is the title';

// bool(true)
var_dump(isset($$tag));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜