User Name
|
VBAssassin |
Unique Hits
|
3,465 |
Real Name
|
Scott Thompson |
Location
|
United Kingdom Lincolnshire |
Occupation
|
Web Technologist & Director |
Gender
|
Male |
Age
|
21 Years Old |
WebSite
|
coderprofile.com/ |
|
|
[PHP] - Lets kill the complex IF
Programming
|
Hi ya guys,
Have you ever nested that many if conditions that your code starts to get quite complicated? Let's give you an example
Just some simple data checks on the $_POST['name'] value. But I'm not happy with that code. For something so simply, why is the code so complex? Let's use a technique with functions to make this much simpler. Then explain how it works in regards to simplifying it.
[code language='php']function get_name() {
//make sure it's set
if (isset($_POST['name']) == false) {
return 'Error Occured'; View In Full
 |
1 Comments |
7.00 out of 10 |
|
|
How to use Memcache on Windows
Web Development
|
I will quickly run you through an example of HOW to use memcache and how it works.
Download Memcache
http://jehiah.cz/projects/memcached-win32/
And load up the .exe - you should just get a blank command box appear - the server is then running on localhost:11211
Install the Memcache extensions in to PHP
If you use something like xamp or easyphp - just enable the memcache exentions (just a case of maybe uncommenting a line or ticking a box like in easyphp).
Code Example
Put that code in a .php page (remember to have the memcache server running). Now simply run the script and it will save my name in memory for 60 seconds! To retrieve the value from memory now put this in the script (within 60 seconds else it will expire from memory).
And you will see that my name is still there!
It's quite simple really. You use add() to add new values to memory where they are View In Full
 |
0 Comments |
8.00 out of 10 |
|
|
PHP Sessions = Member Database Cache
Web Development
|
Let�s go over what a session is.
Sessions
First you call session_start() which gives you a unique ID such as: dde2ds2g67xs2zxjh89s3j8923
Everything you then save to $_SESSION is saved in a file on the server such as:
$_SESSION['message'] = 'hello';
Would be saved to:
tmp/phpsess_dde2ds2g67xs2zxjh89s3j8923
and next time you call session_start(), $_SESSION['message'] will still exist and will have 'hello' in it!
Database Problem
So, you record a members total page hits on your site, and the last time they made a page hit on your site. You keep these stats up to date like this (which is executed on EVERY page hit by the member):
$time = time();
mysql_query("UPDATE `members` SET `timestamp_last_seen` = '{$time}', `hits` = `hits` + 1 WHERE `member` = 'VBAssassin' LIMIT 1;");
Now, all you�re doing is keeping track of the last time they were seen, and the total page hits they have made while logged in.
Solution
You need to keep track of your active sessions u... View In Full
 |
2 Comments |
9.00 out of 10 |
|
|
|
Dynamic Parameters (Using Reflection)
PHP (Hypertext Preprocessor)
|
12 Days Ago
|
6
|
7.75
|
- - -
|
2,468 Chrs
|
|
Allows for you to call a method of a class with the parameters in no particular order! Example:
function print($string, $size = 12, $color = 'red);
If you want to skip size, but you want to chan
|
|
|
Slime Wars Game v1
PHP (Hypertext Preprocessor)
|
42 Days Ago
|
2
|
- - -
|
Yes
|
1,903 Chrs
|
|
Good old slime wars game where you have to try and win by having your colour dominate the board. Simple enough...
I plan on hosting this game on a domain name of its own when i update it to version
|
|
|
Pagination Class
PHP (Hypertext Preprocessor)
|
81 Days Ago
|
0
|
- - -
|
- - -
|
4,548 Chrs
|
|
Takes care of the hard work when creating pagination and can carry across variables between pages in the pages URL. Multiple instances of pagination can be used on a single page.
|
|
Please login to post comments. |
|
Cool, just voted for one :D
|
|
I cant remeber exact but i was looking up 5star rating code and ning
|
|
Well, nope i never thinked to go to a University for Developing. But i might arrange that for the further.
Oh, not yet, but will do.
|
|
Oh i did a fault on my date i will fix that..
I'm 18 years old.. well.. i started with hacking.. and just simple web developping like using CMSes etc..
Regards,
Psylithium.
|
|
Oh well!
I'm a PHP, VB/VB.Net Coder.
And will edit my profile don't worry about that :).
I'm a new member :p.
|
|
Hello!
Nope, i don't know him, and never heard of him before.
I'm fine, thank you.
How are you?
Regards,
Psylithium.
|
|
Yerp :)
Have indeed, opened photoshop and thought i would have a change in avatar.
I guess it does look kinda 3D in a way.
Cheers,
Ant
|
|
Thanks, its kind of my new Official 'face' on the internet.
Also whats up with no spell check on the BBS?
|
|
Hey,
I'm just busy with University. I kind of sucks that I have no time for pet projects anymore (and CP), but whatever.
What have you been up to?
|
|
Ahh, not sure. All I remember is they bought out the company who created it.
|
|
 |
Scott Thompson (21) United Kingdom, Lincolnshire |
|
VBAssassin has 21 fans
become a fan |
|
 |
|
 |
|