Has anyone encountered this oddity?
I'm checking for the existence of a number of directories in one of my unit tests. is_dir is reporting true (1) in spite of the folder not existing at the time it is called. Code looks like this (with a few extraneous intermediate vars to ease debugging):
foreach($userfolders as $uf) {
$uf = spri...
I am trying to paginate the results of an SQL query for use on a web page. The language and the database backend are PHP and SQLite.
The code I'm using works something like this (page numbering starts at 0)
http://example.com/table?page=0
page = request(page)
per = 10 // results per page
offset = page * per
// take one extra record ...
As part of a larger web-app (using CakePHP), I'm putting together a simple blog system. The relationships are exceedingly simple: each User has a Blog, which has many Entries, which have many Comments.
An element I'd like to incorporate is a list of "Popular Entries." Popular Entries have been defined as those with the most Comments in ...
Our system uses Zend WinEnabler. Do you use it? Is it obsolete? Should we stop using it? Is it known to cause handle/memory leaks?
Here is an (old) introduction to it: "PHP Creators Unveil New Product that Makes PHP Truly Viable for Windows Environments"
http://personalweb.about.com/b/2004/03/29/zend-announces-winenabler-enabling-php-fo...
Below I present three options for simplifying my database access when only a single connection is involved (this is often the case for the web apps I work on).
The general idea is to make the DB connection transparent, such that it connects the first time my script executes a query, and then it remains connected until the script termina...
$output = preg_replace("|(/D)(/s+)(/d+)(;)|", "//1,//3;", $output);
I'm trying to replace all alphabetical character followed by one or more whitespace characters (tabs and/or spaces) followed by one or more numerical characters followed by a semicolon with the alphabetical character followed by a comma followed by the numerical digits...
I'm trying to write a Wordpress plug-in that automatically posts a blog post at a certain time of day. For example, read a bunch of RSS feeds and post a daily digest of all new entries.
There are plug-ins that do something similar to what I want, but many of them rely on a cron job for the automated scheduling. I'll do that if I have ...
I'm struggling to implement ACL in CakePHP. After reading the documentation in the cake manual as well as several other tutorials, blog posts etc, I found Aran Johnson's excellent tutorial which has helped fill in many of the gaps. His examples seem to conflict with others I've seen though in a few places - specifically in the ARO tree...
So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes.
class PageAtrributes
{
private $db_connection;
private $page_title;
public function __construct($db_connection)
{
$this->db_connection = $db_connection;
$this->page_title = '';
}
public function get_page_title()
{
return $this->...
Question
I'm fairly familiar with many of the PHP frameworks out there, but I'm wondering which ones actually integrate AJAX functionality and which ones do it well? Ideally I'd love to find a framework that would allow me to avoid JavaScript alltogether (at least for typical/basic JavaScript functionality).
Does such a thing exist? If...
The job at hand:
I want to make sure that my website's users view a page before they start a download. If they have not looked at the page but try to hotlink to the files directly they should go to the webpage before the download is allowed.
Any suggestions that are better than my idea to send out a cookie and - before the download sta...
I'm writing some DB routines and I'm using prepared statements. My environment is PDO with PHP5.
I understand prepared statements primarily provide a performance benefit, as well as some auxiliary bonuses such as not having to manually SQL-escape input data.
My question is about the performance part.
I have two implementations of a g...
I'm pretty sure the answer to this question is no, but in case there's some PHP guru
is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@'
Much like empty and isset do. You can pass in a variable you just made up and it won't error.
...
I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key.
I have done the following:
strtolower(substr(crypt(time()), 0, 7));
But I have found that once in a while I end up with a duplicate key (rarely, but often enough).
I have also thought of doing:
strtolower(substr(crypt(uniqid(rand(), true)...
What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'.
I know there is WP-Cache for WordPress, but I'm writing a custom solution that isn't built on WP. I'm ...
I'm a PHP developer, but honestly my knowledge of server management is somewhat lacking. I fired off a script today that took a regrettably long time to run, and because it had an embedded call to ignore_user_abort(), pressing "stop" in the browser was obviously futile. There was a time limit of 15 minutes enforced in the FastCGI setting...
Hi everyone,
I'm building a PHP page with data sent from MySQL.
Is it better to have 1 SELECT query with 4 table joins, or 4 small SELECT queries with no table join (I do select from an ID). Which is faster and what is the pro/con of each method?
PS. I only need one row from each tables.
...
I'm going to be implementing a PHP/mySQL setup to store credit card information. It seems like AES_ENCRYPT/AES_DECRYPT is the way to go, but I'm still confused on one point: how do I keep the encryption key secure? Hardwiring it into my PHP scripts (which will live on the same server as the db) seems like a major security hole. What's th...
In effect, if I have a class c and instances of $c1 and $c2
which might have different private variable amounts but all their public methods return the same values I would like to be able to check that $c1 == $c2?
Does anyone know an easy way to do this?
...
Here's my first question at SO.
I have a internal application for my company which I've been recently ask to maintain. The applications is built in PHP and its fairly well coded (OO, DB Abstraction, Smarty) nothing WTF-ish.
The problem is the applications is very slow.
How do I go about finding out what's slowing the application down...