Why should I care about PHP Shorthand If Notation or the Ternary Operator
Programming would be a bit useless without being able to evaluate conditions using if/end and switch statements. If/Else statements is obviously a great tool, but they aren’t optimal (or necessary) in all situations. And so I introduce you to … PHP Shorthand If Notation or the Ternary Operator.
Ternary operator takes the form “(condition) ? (true return value) : (false return value)” to shorten your if/else structures.
Continue reading “PHP Shorthand If Notation or the Ternary Operator”
When you’re working with a complex page that has a load of areas on-screen, making use of this jQuery Scroll page to position of an element/div function below to scroll to the location will enhance you’re user experience by saving them needing to scroll… take them straight to it!
Continue reading “jQuery Scroll page to position of an element/div”
Over time, the websites I have been involved in have became more and more complex (and indeed carry more and more traffic).
And so the ever increasing need to optimise and increase the performance of your website (or web-application) becomes more crucial.
As you will appreciate this is a HUGE subject, so I aim to simply put you on the path to devising a better architecture and design. But I will attempt to introduce some ideas to assist…
Continue reading “Hints to help optimise the performance of a PHP website (LAMP)”
Working with Dates and Timestamps is always trying, but using UNIX timestamps can save you a lot of time and hassle!
Continue reading “Working with Dates & Timestamps in PHP”
Get element with CSS class name or id with jQuery, jQuery is extremley powerful and a time (and even life) saver, using jQuery, you can get elements with CSS class name and id easily without too much blood and tears!
Continue reading “Get element with CSS class name or id with jQuery”
OK, a simple thing I know. But one that always occurs.
When using shared hosting (or even your own dedicated servers), those managing those servers do their utmost to make them secure. Among many things this usually includes turning off ‘display_errors’ in the php.ini file.
However, when you’re trying to develop things it is usefull to display errors and warnings, but if ‘display_errors’ is off, you will be scratching your head wondering what’s going on and whats going wrong!
Continue reading “Why does php not show errors? – How to display PHP errors when display_errors is disabled”
Object-Orientated programming is not a new idea! It’s been around and available for a long time in many languages.
With each new version of PHP, new features appear, while existing features are improved. PHP’s object support has been hugley improved since it’s introduction in PHP3 (yes it has had it all this time!). And so with PHP’s object support maturing, the reasons developers might not take an object orientated approach are getting smaller. More recently PHP5′s take on objects is much more powerfull and usable than it ever has been for PHP users – but still not without it’s faults.
A common problem that experienced (and new) PHP developers have when embarking on their object-orientated (OOP) journey is thet they don’t know WHEN to use it properly! As with all things there is a time and place for everything.
For those who do not know about OOP I am not even going to attempt to explain what it is! But fact you have found this article means you probably do, but incase not Wikipedia has good general background info on OOP.
Continue reading “Beginning your journey in Object-Oriented Programming using PHP”
Well, I’m going to try to divulge more of my development experiance to others. Starting with some ‘Tools & Tips‘.
Let me know if there are any topics/questions from all forms of development PHP, Java, .NET .. and management (people & projects) aspects of the IT world too!
Traditionally HTTP is a stateless protocol. That is it is made up of requests and responses and there is no notion of a ‘persistent connection’. This means that there is no way to have consistency or personalisation on the web since there is no way of knowing whom the request came from.
There are 2 primary methods – regardless of platform – that are used as a work-around for this.
First is a cookie. A cookie is a text file that lives on the client’s computer that store values set by your application. In general the file can only be access by the website/domain that issued it. The main problem with cookies is that they are un-trusted. A malicious user could modify the data and cause you problems!
The second – and better – solution is sessions. Similar to cookies, but they reside on the server, and cannot be directly modified by the client. When sessions are used, a cookie is still issued, but this simply holds the ‘session id’. This session id is generally sent by any request after it is created by the app including actions such as form submission. This ‘session id’ is a link to either a file or record on the server – depending how they are stored.
Continue reading “Session Handling in PHP”
AJAX is great… but sometimes it’s too quick if you’re updating… So… How can I make the page wait for a few seconds, then proceed?
Well there are 2 functions PHP has to pause execution. They are:
One thing you may want to keep in mind is that if you are using a for loop and wish to do this, then you might want to increase the timeout:
Very often the need to create passwords or some other ‘unique’ string be it a captcha or for use as unique identifier (UUID).
Here are a few functions I’ve used and refined over the years, 2 types, for password/random string generation and UUID generation.
Generating random strings is pretty simple as it’ll be a password.
However for a UUID there is always the slim chance it’s not unique.
Continue reading “PHP – Generate/Create strong passwords, uuid, random string”
If you are a professional developer (or aspiring) you will inevitably get asked to customise or even better “extend” existing wares.
If it’s a product you are familiar with great! If not I heartilly reccomend spending a little time investigating prior to accepting a job ( ultimatley if they are happy to give
access to their code, if not atleast tell you what’s been used so you cam repliocate it to play with briefly). I know this sounds like a lot of work wich ultimatley – if you
don’t accept the job – you have done for free, but it will save you masses of grief, tears and late nights if you do.
So, I have a few pointers to ‘be aware of’ while evaluating the job and to (generally) identify crappy PHP products/solutions quickly…
Continue reading “Signs of poor PHP ‘products’”
A question I am always asked is about ‘self-submitting’ forms.
Continue reading “PHP Form Action Self submit”
Needed to capltalize Mc’s and Mac’s? Here’s a quick function for it…
Continue reading “Capitalization for us Mc’s and Mac’s!”
Recently I was reviewing the security practices for my users…
I like to get them to change their windows login regularly as it’s used via LDAP etc etc in some cases for loggin into web applications…
Anyway… all the passwords I keep getting from them are very poor, and so I put some guide-lines together for them and thought it’d be fun to share.
I suggest – actually force them – to include characters from all 5 of these rows in passwords…
Doing this will increase the time it takes to get cracked… Now… if you want a really really great password do the above and include an alt-character or two! Here is a table of them: