« Catch 22 | Main | Technorati »
Php
By maurizio | March 1, 2007
Yesterday I was playing around with some php code to see how difficult is to build my own list of visitor. I personaly use an “Extreme Programming” way (more about this on another post..maybe). This way of working is the safest for beginner and learner because it forces you in creating simple programs to understand every single “tecnique” or algorithm you have to use. Of course before doing this you should have at least an idea of what you are plannig to do.
The first test I did was to connect to the Database and get some datas out of it. This is easy. You can find 3423424234234 examples on internet. The second task was a bit more challenging. I wanted to show on a html (or php, that’s the same) page what another php pages gives as result. I tried hard without finding a good example on internet until some good soul today told me what I did know, but I wasn’t able to connect to this problem (sometimes I know the tecnique but I wasn’t thinking about it until someone shows me. And then I react like for the Egg of Columbus story.
The code is simple; here is the first file:
Hi: <script source="b.php"> </script>
And here is the second file:
<?php $value = "hello";
echo "document.write('".$value."');";
?>
When you read it you understand how easy is: the first page is looking for a script (Javascript) so when it reads the second file it’s expecting some Javascript code. That’s why the php parser read my code and generate “document.write(‘hello’);” wich is a simple Javascript command to show ‘hello’ wherever the parser of the first file is.
Simple, isn’it? :)
Apparently, it’s not that easy to write pieces of code in wordpress..
Topics: Programming | No Comments »
Read other related posts:

