Skip to content

php setcookie domain

Some application, not written by me, and not in PHP, creates a cookie for the domain “www.domain.com”. I am trying to replace that cookie. So in php I did: setcookie(‘mycookie’,’mydata’,time() + 2*7*…

PHP array multiple sort – by value then by key?

I have an array of string keys with numeric values for use in a list of tags with the number of occurances of each tag, thus: $arrTags[‘mango’] = 2; $arrTags[‘orange’] = 4; $arrTags[‘apple’] = 2; $…

Lightweight PHP5 based template class/system

Looking at using a template system for a new project, it’s only a small site and don’t want to use the overhead and ‘complexity’ of smarty. I don’t really like template systems that force you to make use of another language just to make it easier for designers (apparently). Somet…

Decimal validation + PHP?

How to do decimal number validation in PHP? (The decimal point is optional) it should accept … 0 , 1 , 2 , 0.123 , 0.2 , 12.34 etc. Answer Would any of these suit your needs? is_float() is_numeric()

Display image based on date in PHP

Somewhere on my computer I had a PHP script for displaying an image based on the date, that would allow me to display different images on specific dates, or between selected dates, and display a …

Best way to manage long-running php script?

I have a PHP script that takes a long time (5-30 minutes) to complete. Just in case it matters, the script is using curl to scrape data from another server. This is the reason it’s taking so long; it has to wait for each page to load before processing it and moving to the next. I want to be able

PHP “&” operator

I’m not a PHP programmer (but know other languages), and I’m trying to understand a web page that was done in PHP (5.1.6) in order to do some changes. The page has the following code (simplified): $…

could static members use nonstatic members and vice versa?

could i use nonstatic members inside a static method? eg. and vice versa that is to say use static members inside non-static methods? Answer From http://php.net/manual/en/language.oop5.static.php Declaring class properties or methods as static makes them accessible without needing an instantiation of the clas…