gets you the words from words.txt, 🙂 if you have one, and strips off the newline character, before assigning each word to array element. otherwise you may need array_walk or foreach to do this..
You probably already know the method of making any kind of revenue from the internet depends on a well designed website. What most of us don’t realize (or refuse to admit) is that sites need not have to look perfect or be professionally designed to be successful.
Don’t take it by the literal meaning!
In the short, any site that generates income is a successful site. From a marketing point of view, any site which brings in an income can be considered as a well designed site. Most of us can’t get our heads around this fact: some of the most basic or aesthetically unpleasing sites can be the most profitable. We don’t usually need a perfect site.
Our site need not have to be a killer design to generate revenue. The site https://www.bizwaremagic.com which the maintainer designed from scratch now brings in over 50,000 visitors a month and has Google PR6. All that is not really important, what is important is that the site brings in money each and every day! It is a profitable site, it’s not pretty but it works. He earns revenue from Google Adsense, affiliate sales and have even formed partnerships with other sites and businesses on the web.
One would think what is there in configuring two mysql server, or even think what the purpose behind achieving this. Well there are different requirements, and these different requirements may lead to take us through various possiblities. For instance it may be that certain projects may need the advanced features of MySQL 5.2, where as some others could even be run on MySQL 4.12. In my case it was very peculiar and different, in that about half of our projects used transactional tables and other half could go without transactional tables. And we preferred that these two were configured on two different mysql servers. When the system was explained and the need described to the management, they ruled out the option to have different dedicated server for those projects which was not using transactional tables. Thus I thought about configuring multiple mysql server on the same hardware and operating system.
If a method can be static, declare it static. Speed improvement is by a factor of 4.
Avoid magic like __get, __set, __autoload
require_once() is expensive
Use full paths in includes and requires, less time spent on resolving the OS paths.
If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()
See if you can use strncasecmp, strpbrk and stripos instead of regex
preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4
If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.
Error suppression with @ is very slow.
$row[‘id’] is 7 times faster than $row[id]
Error messages are expensive
Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.
In Saturn we had a handful of XUL projects where the XUL part was for backend administration. It was in the year 2004, when we developed most of the packages, and we were on php 4.2. There was heavy use of WDDX serialization, since that was found to be easy, we never knew about soap and soap implementations. By the end of 2005, most of the projects got woundup, and our XUL first hand developer had also quit. Since then we were swaying away from XUL development, and by mid 2006, we had almost dropped any further XUL support, as well as development.
Recently, the management decided to revamp, and pull out one of the old project to be reworked as a new product with solid backend. It was then I got bitten by the WDDX bug, [#38839], and I overcame that by patching the latest hourly patch.
Later on our COO needed the same project to be deployed on his laptop, where we downloaded the TSW which is Easy, modular and flexible WAMP bundling Apache2/SSL, MySQL4, PHP4, Perl5.8/ASP, Python2.3, Tomcat5, FirebirdDB, FileZilla, Mail/News-Server, phpMyAdmin, Awstats, WordPress, etc. It also includes a web-GUI to control/manipulate all bundled services. But even with the php 4.3.4, it also seemed to have the WDDX bug, but in a different way. ie; when the XUL application sends an AJAX request, where the output was expected as a wddx serialized string, the Apache server started crashing.
Finally in the TSW also, I downloaded a cvs snapshot and patched that, then the error went away.
Myself is more or less active at RAC, and wanted to show off my buyers comments in a page for promoting me. And wrote this script rac2rss. Download from here.
The main script is rac2rss.php, change the line [php] $coder_id = “1242159”; [/php], in rac2rss.php to get your resume. [php] $myFileMgr = new fileMgr(‘./cache’,7 * 24 * 60 * 60); [/php] defines the cache, and the cache folder should be world / webserver writable, and it can be outside web path for security reasons, only that the absolute or relative path should be provided, as well the lifetime is in seconds, actually in the said script I have put it as a week.
As a last note, thanks to all members and maintainers of RAC, for making it a wonderful place for all of us.
We always try to store images in a web path where heavy image linking is needed, and mostly the images will be categorised in some sort of directory tree.. to limit the no of files in a folder.
Once editing, for example, re assinging a set of students from one scientist to another, was needed, and the hell, we had to face.. finally the following piece of code was written, for a future reuse.
<?php function mkdir_r($dirName, $rights=0777){ $dirs = explode('/', $dirName); $dir=''; foreach ($dirs as $part) { $dir.=$part.'/'; if (!is_dir($dir) && strlen($dir)>0) mkdir($dir, $rights); } }
To quote the zapatec site ” The Zapatec DHTML Tree is an easy, attractive, and versatile way to display information. You can use the DHTML tree as a menu, a site map, or a way to display your data. Our DHTML Tree works in many different browsers, but if visitors use older browsers, they will still be able to see and use the underlying HTML code. ”
I did find this very good, and in the sense that it provides a method for the Search Engines to see all the links. Recently in an administrative backend, I needed to provide a method to browse multilevel deep category subcategory, where they add new products, to their existing line, for which I did choose the lite version of zapatec suite.
The generation of nested ul/li tags for the tree was a real pain for me, from the existing database. And I thought about a wrapper which could do the job if provided with an array of data rows. Hence I made the class-tree.php. The included file is having an implementation sample which will need the lite version from zapatec site.
The sample implementation with the help of zapatec could generate a tree as shown from the code attached below.
from
To start with the implementation, we create an instance of the zptree after including the class-tree.php, and passing the path of zapatec js files.
Then initiate the tree data using $catTree->treeData = array(); Then go along selecting the data from mysql using the select statement select category_id as id,category_name,parent_category_id from category order by parent_category_id, inside a while loop, the tree data is added to the member array, while($rd = $db->fetch_array($rs)) $catTree->treeData[] = $rd;
The attached class-tree.php also has an example implementation at the end, which should be removed before using in production.
Please excuse me about the sloppy documentation, since I am no good at explaining things.
The code: Source File in text
I usually use this to check the generation time for any page. There are critical applications which we are developing and will need less than a milli second generation time.