How to include a TCL script in a PHP page ?
Short answer : echo
Here’s my Pluton code.
You’ll certainly need some libraries ; I’ve a TCL script initializing MySQL connection and another with user profiles functions. Let’s put all in a directory, chdir to it, and no need to worry about paths.
Of couse, after the script, we come back to our initial directory to avoid broke the end of our php app.
tclsh is a shell-like TCL interpreter, and
is the backtick operator, executing the command inside and returning result. Of couse, tclsh must be in tour path. And you should consider use tclsh84 or tclsh85 instead. If I’ve written tclsh to get TCL 8.4 on Guenwhyvar, the FreeBSD Espace Win prod server and TCL 8.5 on Leviathan, my laptop.
We pass two arguments at our TCL script, the user id and session id of the logged user. I presume user_id is satisfactory but we’ll see in the future.
Oh, btw, our user_id is [lindex $argv 0] and session id [lindex $argv 1], tclsh putting our args in argv variable, lindex $list $n returning element $n of our list $list.
This is a webpage viewing #Win projects. I had already the TCL output in SurfBoard so why recode it again in PHP ?
In core.tcl we’ve Pluton user profile functions and two interesting :
MySQL.tcl opens a MySQL connection :
Then Projets.tcl contains functions I’ve copied from my previous Su
Finally, here the extra functions in core.tcl to get a fully functionnal code 😉
I hope you’ve catched return is not necessary in TCL, by default a function return the result returned by it last instruction (so getnom proc returns getuserinfo result). Eminently readable source code 🙂