[Desktop] PHP embed class (3rd Party)
I was reviewing this guide: http://developer.appcelerator.com/doc/desktop/php and I was unable to reproduce. For instance I took a premade class from SF (getID3) and tried to use it as a it described and was never able to access its functions. Is this a known issue?
3 Answers
-
Its funny that this hasn't been answered in 10 months, and has nearly 200 views.. I seem to have the same issue, I get "Couldn't execute function krollnamespace__1\testexample" when I try to call testexample(); from within a javascript block, and with my php function testexample in a block before or after.. The ironic part, is it works the other way, js objects can be used in php, but php functions cant be used in js… It would be great if I could figure this out.. But the examples I expected to work, dont… and it's another example I have found that has done this to me on this site :/ I think someone needs to re-think their documentation…
-
Well I think I've figured it out. All you have to do is create an instance in the class file of that class and assign it a variable. Then you will be able to access that instance of a class in the other files.
class myclass{
function
}$class = new myclass();
and then in
index.htmlecho $class->function;
-
I think the answer for this would be the answer from this other question on here. http://developer.appcelerator.com/question/119717/desktop-php-including-classphp-files-and-the-kroll-namespace-error.
Basically, if you include("a_php_file.php"); within a <script type="text/php"></script> block, or if you do it within the preprocessed php (not 100% sure on that, but I wouldn't see how this would differ). Then to gain access to those functions, and not get the "krollnamespace1\functionNameCalled" error, you simply call the function with a backslash () before the function name. Just like you would do if you were to try and call it specifically from the krollnamespace, but in the case of no namespace, its the root namespace.
So to call "functionNameCalled();", if it resides in an included() php file, you would simply do "\functionNameCalled();"