PHP / Wordpress - Loading a remote XML file - php

How can a get a object variable from a remote XML file, for example this one ?
In PHP5 it works fine with simplexml_load_file(), but I need this to work in PHP 4 also. How can I do that?
Or is there any built-in WordPress function that can load xml files? I tried using the WP's SimplePie class, but I get a weird object variable (with incorectly named fields etc).

If you want to use the smipleXML functions in PHP4 include this class ( I have used it and it works like a charm)
http://www.phpclasses.org/package/4484-PHP-Load-XML-files-in-PHP-4-like-SimpleXML-extension.html

Related

Is it possible to load a php file in codeigniter dynamically?

I want to load a php file dynamically. for example i have a website and i added new php file and it will load the new php file. is it possible without going through controller?
Try this, if you are not using cURL.
file_get_contents('http://YOUR_CODE_URL.com/send.php?'.$getdata, false, $context);
Furthermore, the method defaults to GET so you don't even need to set options, nor create a stream context. So, for this particular situation, you could simply call file_get_contents with the first parameter if you wish.

Smarty get current template filename / line

I would like to get the current template file / line from a plugin function in smarty for profiling/debugging purposes.
Is it possible to do by using the passed $smarty object ?
something like this
function __smarty_add_javascript($params, $smarty){
Profiler::console('Add javascript #[FILE]#[LINE]');
Controller_Template_Base::getInstance()->javascripts[] = array_pop($params);
}
I am able to access the filename by using $smarty->source->filepath however i couldnt find any line information.
I don't think you can access the original template's properties from a plugin in runtime. But you can use the http://php.net/debug_backtrace function to access the caller place's informations. (Of course this information will be based on the compiled file, not the original. But It is better than nothing.)

How to get array with PHP on Joomla?

I've been making a Joomla module. I've mostly been successful, but I have one question: how do you get the image_fulltext variable to contain the following?
{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"images\/sampledata\/parks\/landscape\/800px_cradle_mountain_seen_from_barn_bluff.jpg","float_fulltext":"","image_fulltext_alt":"Konsultasi belajar","image_fulltext_caption":""}
This functionality can be found inside the PHP library see json_encode and json_decode.

Using PHP to create AS2 functions

Is it possible to use PHP to create AS2 functions? Like load the php file from the swf file and have it [the php file] send a string like
function test(){
trace("test");
}
and somehow get AS2 to read it as a function. The reason I want to do this is because I don't want anyone seeing 2 of my good functions in my flash file. I know about SWF Encrypters and things, but none of then can truly keep one out. Thanks.
Sorry for bad grammar or anything wrong with this post - it's 4 am here.
I don't think it's possible. I mean you could make calls in POST from flash and get php to send you back some code. But it would return as String so you'd have to code a sort of parser to transform that string in to real code in AS2, and that could be pretty complicated.
Not sure but you could make the server handle external .as files with PHP. Thus, your .as fiel would run as regular PHP and as far as there is no problem with the Action Script code in it it should be handled by Flash as a regular .as with external code... You can do this in the .htaccess file for example, with a statement similar to this, that adds the .as extension to the PHP5 handler:
AddHandler x-httpd-php5 .as

custom php function creation and install

I would like to know how to create a php function that can be installed in php
just like the already built in functions like :
rename
copy
The main point I would like to achieve is a simple php function that can be called from ANY php page on the whole host without needing to have a php function within the php page / needing an include.
so simply I would like to create a function that will work like this :
location();
That without a given input string will output the current location of the file via echo etc
Well, there are a couple of options here. One of them is to actually extend the language by writing an extension. You'd have to muck around with the PHP source code, write it in C, and deal with the Zend Engine internally. You probably wouldn't be able to use this on a shared host and it would be quite time consuming and probably not worth it.
What I would do is put all of your functions into a separate PHP file, say helper_functions.php. Now, go into your php.ini and add the directive: auto_prepend_file = helper_functions.php. This file should be in one of the directories specified in your include_path (that's a php.ini directive too).
What this does is basically automatically put include 'helper_functions.php'; on every script. Each and every request will have these functions included, and you can use them globally.
Read more about auto_append_file.
As others have said, there's probably an easier, better way to do most things. But if you want to write an extension, try these links:
http://docstore.mik.ua/orelly/webprog/php/ch14_01.htm
http://www.tuxradar.com/practicalphp/2/3/0
So you want to extend PHP's core language to create a function called location(), written in C, which could be done in PHP by:
echo __FILE__;
Right. Have fun doing that.

Categories