Skip to content
Advertisement

Tag: php

PHP: Cookie domain / subdomain control

I’m working on a site with multiple subdomains, some of which should get their own session. I think I’ve got it worked out, but have noticed something about cookie handling that I don’t understand. I don’t see anything in the docs that explains it, so thought I would see if anyone here has some light to shed on the question.

Algorithm for generating a random number

I’m looking to generate a random number and issue it to a table in a database for a particular user_id. The catch is, the same number can’t be used twice. There’s a million ways to do this, but I’m hoping someone very keen on algorithms has a clever way of solving the problem in an elegant solution in that the

PHP replaces spaces with underscores

I have the problem, that PHP replaces all spaces with underscores in POST and GET variables. For example if I have the URL: http://localhost/proxy.php?user name=Max the browser will convert it to http://localhost/proxy.php?user%20name=Max. But if I give the $_GET parameters out, the key is not user name but user_name (note the underscore)! Is there any possibility to change this behaviour? Answer

Increase days to php current Date()

How do I add a certain number of days to the current date in PHP? I already got the current date with: Just need to add x number of days to it Answer php supports c style date functions. You can add or substract date-periods with English-language style phrases via the strtotime function. examples… or

Regex for names

Just starting to explore the ‘wonders’ of regex. Being someone who learns from trial and error, I’m really struggling because my trials are throwing up a disproportionate amount of errors… My experiments are in PHP using ereg(). Anyway. I work with first and last names separately but for now using the same regex. So far I have: Any length string

Advertisement