Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-10-15 02:21:28
- minimal design
- Member
- Registered: 2006-10-15
- Posts: 38
PHP Function call from external php file
I put something like that in the header:
<code><txp:php> require_once(‘http://my_site/_php/my_file.php’); my_function(); </txp:php></code><br />
But I get a fatal error saying the function doesn’t exist. The function is declared in the required php file, but I guess that’s not how it works?
Is there documentation on how Textpattern interacts w/ PHP? I couldn’t find it. I guess I’m not too clear on how Txp and PHP are parsed in context. Is txp always first? I tried to put some txp into some PHP code just to see but I got errors too…
Offline
Re: PHP Function call from external php file
Also see:
Include a file
Offline
#3 2006-10-15 17:54:03
- minimal design
- Member
- Registered: 2006-10-15
- Posts: 38
Re: PHP Function call from external php file
Thanks for the links, but I actually read that before. I still don’t get what I’m doing wrong. I’m not using a variable without global scope declaration. I’m running a function declared in the file from within the same txp PHP call and the function is undefined. An example on what syntax you would use to first include a file with functions inside and then call one of those functions would be great help.
I realize that my question is probably dumb… but we’re all dumb once in a while right? ;)
Offline
Re: PHP Function call from external php file
You’re using an URL instead of a file path in the include. It should look more like this:
<code><txp:php> require_once(‘/home/user/my_site/_php/my_file.php’); my_function(); </txp:php></code>
Offline
#5 2006-10-16 18:30:12
- minimal design
- Member
- Registered: 2006-10-15
- Posts: 38
Re: PHP Function call from external php file
Thanks a lot – I knew I was missing something stupid… That did the trick :)
Offline