Author |
Message |
lonea
Joined: 24 Jun 2019 Posts: 2
|
Posted: Mon Jun 24, 2019 1:42 am Post subject: Dynamic key inside a Class? |
|
|
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 |
|
 |
alastair
Joined: 23 Feb 2010 Posts: 407
|
Posted: Mon Jun 24, 2019 9:00 am Post subject: |
|
|
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 |
|
 |
lonea
Joined: 24 Jun 2019 Posts: 2
|
Posted: Tue Jun 25, 2019 6:38 am Post subject: |
|
|
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 |
|
 |
alastair
Joined: 23 Feb 2010 Posts: 407
|
Posted: Tue Jun 25, 2019 8:21 am Post subject: |
|
|
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 |
|
 |
|