ionCube Logo
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


 
Post new topic   Reply to topic    ionCube Forum Index -> ionCube PHP Encoder

Dynamic key inside a Class?

Author Message
lonea



Joined: 24 Jun 2019
Posts: 2

PostPosted: Mon Jun 24, 2019 1:42 am    Post subject: Dynamic key inside a Class? Reply with quote

Read over the manual and it didn't say whether I can variable inside a class to use as the dynamic key.

I see the following is not allowed.

Code:
// Attempt to use a static method will be disallowed.
// @ioncube.dk MyClass::StaticMethod("a") -> "my static res"
// Attempt to use an instance method will be disallowed.
// @ioncube.dk $obj->mymethod("arg1","arg2") -> "obj res"
// Cannot use variables for function calls.
// @ioncube.dk $f("pear") -> "apples and pears"


However, my script is as follows

Code:

Class MyClass
    Private $dkeyvariable

function LicenseCheck{
    if license is valid; set $this->dkeyvariable = abc;
}

// @ioncube.dk MyClass::$dkeyvariable -> "abc"
other functions{}
[/code[

I tried this but it doesn't work. Nowhere in the manual mentioned I can't use the dynamic key inside a class. Can somebody clarify ?
Back to top
View user's profile Send private message
alastair



Joined: 23 Feb 2010
Posts: 371

PostPosted: Mon Jun 24, 2019 9:00 am    Post subject: Reply with quote

Hi,

Glad to hear you are using dynamic keys!

You cannot use a property of a class as a dynamic key, You can only use global variables. So MyClass::$dkeyvariable would not work.

However, you can create instances of classes within dynamic key functions and get property values that way. You can also use static properties and methods of classes within dynamic key functions. Obviously in each case those have to be publicly accessible.
_________________
Alastair

ionCube
Back to top
View user's profile Send private message
lonea



Joined: 24 Jun 2019
Posts: 2

PostPosted: Tue Jun 25, 2019 6:38 am    Post subject: Reply with quote

Thanks, so in the case of if I use a global variable in the class.

Do I use the following?

Quote:
// @ioncube.dk $globalkeyvar -> "str" RANDOM


or

Quote:
// @ioncube.dk global $globalkeyvar -> "str" RANDOM


alastair wrote:
Hi,

Glad to hear you are using dynamic keys!

You cannot use a property of a class as a dynamic key, You can only use global variables. So MyClass::$dkeyvariable would not work.

However, you can create instances of classes within dynamic key functions and get property values that way. You can also use static properties and methods of classes within dynamic key functions. Obviously in each case those have to be publicly accessible.
Back to top
View user's profile Send private message
alastair



Joined: 23 Feb 2010
Posts: 371

PostPosted: Tue Jun 25, 2019 8:21 am    Post subject: Reply with quote

Hi,

For the dynamic key specifier you just write,

// @ioncube.dk $globalkeyvar -> "str" RANDOM

So you should not include the "global" keyword.
_________________
Alastair

ionCube
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ionCube Forum Index -> ionCube PHP Encoder All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum