/    Sign up×
Community /Pin to ProfileBookmark

Is is possible to register a global variable from an Object?

I am working on a set of ASP.Net style server controls to use a framework for interacting in a more meaningful and intuitive way, with forms and MySQL. In ASP, setting the Id attribute of a control makes it immediately available for use elsewhere by referring to the id.
i.e.

[code=php]<form runat=”server”>
<asp:Image id=”img1″></asp:Image>
</form>
<script runat=”server”>
Sub Page_Load
img1.src = “foo.jpg”
End Sub
</script>[/code]

I already can access the attribute (which are stored in an array) simply by running

[code=php]$markup = “<span class=’foo’>text</span>”
$e = new Element($markup);
$e->id = “myspan”
print $e;
// this will print the following:
//<span class=”foo” name=”myspan”>text</span>[/code]

I tried the following, which did not work (right now, I am calling $e->Register() explicitly):

[code=php]class Element
{
//…
public function Register()
{
global ${$this->id};
${this->id} =& $this;
}
//…
}[/code]

Does anyone have any ideas?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @aaronbdavis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...