开发者

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

开发者 https://www.devze.com 2023-01-10 17:18 出处:网络
开发者_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.
开发者_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

精彩评论

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