Total Pageviews

Thursday, November 3, 2011

Tuesday, November 1, 2011

variables in PHP


Some key points to remember when declaring variables in PHP
  • Remember to always put $ sign in front of variable names. That tells PHP that we're working with a variable.
  • In PHP a variable name must start with a letter or an underscore followed by combination of letters, number or underscores.
  • PHP variables are case sensitive, that means they could be either lower case or upper case or combination of both.
  • You don't have to worry about declaring the type of the variable. For example strings and integers are declared the same way.
  • It's good practice to initialize a variable i.e. assign it a value. Uninitialized variables in PHP have a value of either false, empty string or empty array.

Howto add fonts to Ubuntu 11.10



There is a lot of fonts in Ubuntu 11.10 repository but not enough to maintain the stability of documents created from Windoze environment because you need the same font used for those documents yet some of them were not in the repository at all. Here is what I've done to manage this :

1. Create a .fonts folder in your Home directory
2. Copy the ttf files you have (you can download some free true type fonts or just copy it from Windoze folder.
3. Open your terminal emulator and type sudo fc-cache -fv
4. Done

Sunday, October 30, 2011

PHP quick checklist ..


PHP quick checklist The main points:



  • Always give PHP pages the correct filename extension, normally .php.
  • Enclose all PHP script between the correct tags: <?php and ?>.
  • Avoid the short form of the opening tag: <?. Using <?php is more reliable.
  • PHP variables begin with $ followed by a letter or the underscore character.
  • Choose meaningful variable names and remember they’re case-sensitive.
  • Use comments to remind you what your script does.
  • Remember that numbers don’t require quotes, but strings (text) do.
  • You can use single or double quotes, but the outer pair must match.
  • Use a backslash to escape quotes of the same type inside a string.
  • To store related items together, use an array.
  • Use conditional statements, such as if and if... else, for decision making.
  • Simplify repetitive tasks with loops.
  • Use functions to perform preset tasks.
  • Display PHP output with echo or print.
  • Inspect the content of arrays with print_r().
  • With most error messages, work backward from the position indicated.
  • Keep smiling—and remember that PHP is not difficult.