PHP

PHP: Writing your own functions

December 16, 2011

“All custom functions should start with xxx_ so that the developer knows a native PHP function is not being called.* where xxx == your initials, or the project’s initials, or …” An example custom function style: function pwb_my_function($parameter1, $parameter2) { global $an_outside_variable; .... return true; } functions with optional parameters suppose you are using a function with 1 param, and in some new cases,...

Read more »

Enhancing, expanding limits, customizing, phpMyAdmin

October 29, 2011
Enhancing, expanding limits, customizing, phpMyAdmin

The database tool, phpMyAdmin is NOT the only mysql database tool but it is and has been, the most popular and most awarded among MySQL administrators and developers. It was mentioned by the author of the first php and MySQL book I read. The administrators and developers I have met since, all use it. It is also one which can be installed on the...

Read more »

How to install and customize-personalize Zen-Cart

October 28, 2011
How to install and customize-personalize Zen-Cart

Tutorial help: how to find settings to set up, customize, Zen-Cart Fast. What Zen-Cart Won’t Tell You Running the installation program is easy. The time consuming part is removing their sample store demo files and changing ZC’s settings which are scattered all over. I made changes to the html several times because I did not know there was some setting in admin. The admin...

Read more »

Internet Hacking 101, with PHP

June 1, 2011

The point is, a web site (blog?) with an option or requirement to login before commenting (or blogging) and no captcha, may be easy to get into as an admin. Make sure your web site is secure. Micah Lee, in 2600, The Hacker Quarterly tells how to “write code that automatically loads web pages, submits forms, and [can create an admin user-id in WordPress...

Read more »

quiz yourself on PHP

May 17, 2011

PHP 1.) The eregi() function is deprecated in PHP 5.3+ A. TRUE B. FALSE 2.) Which of the following will be most likely to work as intended: A. mail($headers, $body, $subject, $to); B. if ($i = $item) C. foreach ($i=0;$i $v) E. none of the above 3.) Which of the following is a valid php statement A. print ("<p> Hello World </p>"); B. echo...

Read more »

Clean up WordPress

May 7, 2011

There are some problems with WordPress which can be easy to fix if someone would just tell you how. Some issues involve portability: when you change internet hosting providers, and when you have a copy of your web site, certainly your wordpress blog, on your pc, it is a backup copy, and a place to safely try out things like new plugins and themes...

Read more »

Caching, the ultimate speed-up for wordpress

April 19, 2011

All dynamic web sites are built from server side programs accessing databases, and the more code, the more it is broken up – into separate files, the slower the access. Starting with the index.php, there are well over 2 dozen php programs that have to be accessed from the disk, and the fastest SCSI hard disks are still 1000 times slower than RAM. One...

Read more »

PHP Fatal error: Cannot redeclare

October 18, 2010

” Fatal error: Cannot redeclare () … ” I defined a function (fff) in the top of my pgm. (not in a loop) it spanned from line 5 to 11 and used it in the program, later. I got this error msg: Fatal error: Cannot redeclare fff() (previously declared in /…/xxx.php:5) in /…/xxx.php on line 11 clearly, I only defined it once in the...

Read more »

two online PHP tests

August 25, 2010

This is information for some on-line PHP tests: Even when you’ve been developing in PHP for a few years, a valid concern is whether an exam asks questions that are tricky or obscure. If so, you can miss questions on topics that you understand very well. Here are some obscure bits of information from just such a php test. int xml_parse ( resource $parser,...

Read more »

Function: Convert Numbers to Words

August 8, 2010

This little, recursive, script is to convert a number, an integer, to words. It has an upper limit of 999,999,999 but you can expand or reduce it from there. Put the function in your include file and try it out. /* * Function: number_to_words * Description: recursive numerics to words function * Converts a given integer (in range , inclusive) into * alphabetical format...

Read more »

Syntax Check a PHP Pgm

May 14, 2010

Be sure your error reporting is turned on: (for your testing copy or for your IP address) @ini_set('display_errors', '1'); error_reporting(E_ALL ^ E_NOTICE); If it is and you still get nothing but a blank page … then, by all means, your next step might be to take the syntax check option built into PHP! From a linux/unix command line (terminal session), run php with its...

Read more »

PHP(6): Character encoding and other new features

April 13, 2010

The Internet is converging on UTF-8 for a common / universal character encoding. Set your apache environment to utf-8 by adding ‘AddDefaultCharset utf-8’ to your .htaccess. If you do not use apache add ‘default_charset utf-8’ to your php.ini. You have to do either of them (not both), php will use the apache setting where needed. And, of course, your html-header: ‘< meta http-equiv="Content-type" content="text/html;...

Read more »

SQL db Injection, Cross-Scripting, RFI, and LFI

March 27, 2010

It is possible for a hacker to enter the following seemingly innocuous text into the UserName textbox to gain entry to the system without having to know a valid user name and password: ‘ Or 1=1 — The hacker breaks into the system by injecting malformed SQL into the query. This particular hack works because the executed query is formed by the concatenation of...

Read more »

Comparing OOP in php, java, and C++

March 18, 2010

Sample introductory Object Oriented Programming code in php, java, and C++ showing the similarities and differences. With the possible exception of large, long-term projects, OOP, despite all the hype, is a lot more expensive to write and to maintain than clean structured code. The reality of it does not live up to the theory, and the hype is often “smoke and mirrors” unfortunately. This...

Read more »

php Number Formatting, Rounding, and Incrementing

February 10, 2010

updated 2019-09-15 Checking ctype_digit() only checks strings from the manual: $strings = array('1820.20', '10002', 'ws123'); foreach ($strings as $testcase) { if (ctype_digit($testcase)) { echo "The string $testcase consists of all digits.\n"; } else { echo "The string $testcase does not consist of all digits.\n"; } } The above example will output: The string 1820.20 does not consist of all digits. The string 10002 consists...

Read more »