Skip to content
Advertisement

how do I declare a variable outside a public static function in php?

I am trying to declare a variable outside a public class in PHP, but for some reason, it does not work.

Here is my code

JavaScript

now, when I save the file I get catid__1487393557.png, it completely ignores the $catID.

Now, when I do this below it outputs the right thing.

JavaScript

This outputs this: catid_33234532_1487393557.png

Advertisement

Answer

You can try global variable to declare variable outside function

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement