GIDNetwork > From C++ to PHP
Register
« Beginning Python Tutorial (Part 2) A Random Dispersion Array - C++ console »

From C++ to PHP

by: cable_guy_67 - Aug 02, 2005

Ok, here I go again on a journey started because of a post on GIDForums™. The purpose of this document will be to track my path from a simple C++ console application to a C++ class extention for PHP.

I wrote the console application after reading a request for a better way to handle rotating individual (AdSense) publisher ids in a random and fairly weighted way. The code itself isn't exactly groundbreaking, but my long term goals may come in handy to someone else. Since there is this great way to speak to the world (or at least one or two people) I once again sit down with a notebook at my side and piles of code in my editor.

Introduction : a randomly weighted dispersion array

Planned chapters

  • Chapter 1 - Console C++ Application that creates the random dispersion list

  • Chapter 2 - Port co:de to PHP

  • Chapter 3 - HTML front end that mimics the initial console application

  • Chapter 4 - Extend the HTML frontend to interact with the PHP functions

  • Chapter 5 - FLTK APP that duplicates the current code

  • Chapter 6 - Wrap the PHP code in a class to make usage easier

  • Chapter 7 - Create a queue class to handle the dispersion array

  • Chapter 8 - Catch the FLTK App up with the queue class

  • Chapter 9 - Catch the c++ console application up with the queue class

  • Chapter 10 - Create a Makefile to handle building the individual applications

  • Chapter 11 - Create a PHP extension with all current code (PHP code)

  • Chapter 12 - Create a PHP extension with all current code (C++)

  • Chapter 13 - Create a PHP extension with all current code (C++ class)

  • Chapter 14 - Summation and discussion of the completed project. It should be a control panel for the system itself.

There is some reasoning behind this all. For one, I envision myself as a budding programmer and at 38 I guess I need to get a move on it. :wink: Everyone needs to start out somewhere and I really enjoy the artistic side of coding. Working with C++ is great. It gives me so much more power to create then I had thought possible and while it can be trying at times, I have been enjoying the journey. Who knows, perhaps I'll even get a gig doing this for more than fun one day. For now though, I remain a Hobbyist Coder, doing all this for the enjoyment of it.

I have become fairly proficient with C++ over the last year. That is to say, I have loads to learn, but can usually find what I need to know and complete a task. There is just so much information at your fingertips if you can use a search engine and have some time to invest.

PHP is a new addition. I have recently begun to learn to use it. Since much of the syntax is not too far from C++, it is more a matter of reading up on what is available to use instead of learning a whole new language. I detest the flexible variables at the present time. I actually like the structure imposed by C++. Chalk it up to the learning curve I guess. Maybe I will come to like the loose typing but for now, I miss declaring a type and having to work from there.

HTML is another matter altogether. I absolutely hate this stuff. It is so simple yet something of a thorn in my side. Look for my version of an extended class based on the ideas posted here along the way. All I really care about is simple forms to use as a UI anyhow.

The FLTK code (and Makefile) will be to round out the package. I want to see how the code will relate to each portion. That is also the reason for keeping the console version up to date with the whole project. Cross use of code is something I hope to explore along the way if for nothing else than to show the relationships. Perhaps, if my C++ skills progresses far enough, I could develop a factory class to create each type based on the same core code. If I can get to that point I should have the background to attack my pet project, a new and improved version of fluid for the FLTK library. For now though, it is just a long term goal that remains on my TODO list. There are many, many steps to take before that becomes a reality.

Follow along on my trip if you will. I still work as a cable tv contractor in Eastern PA, USA though, so the time frame for completion may jump back and forth from manic coding benders to little or nothing for a week or so. Bear with me and I hope that you find the information interesting or helpful. At the very least I hope you don't find it useless garbage. If you do, oh well..

One last thing to add after today's trials by fire. I had the PHP version working nicely. I mocked up the publisher ID array so I could see if things were going as planned...

Yeah, what just happened? Why am I pegging my processor at 100% and losing control over Apache? Stupid web projects. :) All I can say is, Make changes slowly and render at every step. Use echo like you would use cout or printf. Seriously. I spent two or three hours just because I placed one set of parenthesis incorrectly. THEN I made some further "improvements" to the web interface and, well, maybe some mean words were spoken. I hope my computer gets over it. :wink:

The moral of the story is, no matter how stupid that I think an unnamed text markup system is, I can always be stupider. Hands down.

Ain't learning grand!?

Would you like to comment? This story has been viewed 17,020 times.
« Beginning Python Tutorial (Part 2) A Random Dispersion Array - C++ console »

__top__

Copyright © GIDNetwork™ 2001 - 2024

Another website by J de Silva

Page generated in : 0.00742 sec.