php

How are echo and print different in PHP?

Is there any major and fundamental difference between these two functions in PHP? ...

ColdFusion vs PHP

Can anyone share with me (without fervent evangelism, please) any comparative experiences you might have with regard to ColdFusion and PHP in developing internal enterprise browser-based applications? Specifically (but not limited to): 1: Do the rapid-development characteristics of ColdFusion compensate for any performance issues resu...

Solving the shared-server security problem for Python

So my group is trying to set up a shared-server environment for various and sundry web services. I think we've settled on setting disable_functions and disable_classes site wide in php.ini and php_admin_value to force open_basedir in each app's httpd.conf for php scripts, and passenger's user switching for ruby scripts. We still nee...

Automatically joining tables without breaking default behaviour in Zend Framework

Hi everyone, The situation is as follows: I've got 2 models: 'Action' and 'User'. These models refer to the tables 'actions' and 'users', respectively. My action table contains a column 'user_id'. At this moment, I need an overview of all actions, and the users to which they are assigned to. When i use $action->fetchAll(), I only have ...

How to connect to 2 databases at the same time in PHP

I am trying to connect to 2 databases on the same instance of MySQL from 1 PHP script. At the moment the only way I've figured out is to connect to both databases with a different user for each. I am using this in a migration script where I am grabbing data from the original database and inserting it into the new one, so I am looping t...

Touchscreen-Oriented Website Development Recommendations for Non-Microsoft Platform

We are currently designing a website that will be accessed from kiosks in a museum. Users will need to be able to browse through a number of different web pages that will currently contain static HTML content as well as go through various interactive presentations that will be based on flash and run in flash player. Users may need to inp...

Validating Crontab Entries w/ PHP

What is the best way to validate a crontab entry with PHP? Should I be using a regex, or an external library? I've got a PHP script that adds/removes entries from a crontab file, but want to have some way to verify that the time interval portion is in a valid format. ...

How do I stop bots from incrementing my file download counter in PHP?

When a user clicks a link to download a file on my website, they go to this PHP file which increments a download counter for that file and then header()-redirects them to the actual file. I suspect that bots are following the download link, however, so the number of downloads is inaccurate. How do I let bots know that they shouldn't fo...

Overwite Line in File with PHP

What is the best way to overwrite a specific line in a file? I basically want to search a file for the string '@parsethis' and overwrite the rest of that line with something else. ...

PHP Script Version Checking/Notification

How can I check the version of my script against an online file to see if it's the latest version? For clarification, I'm talking about a script I wrote, not the version of PHP. I'd like to incorporate a way for the end user to tell when I've updated the script. ...

How best to resize images off-server

I have a site that users upload images to. Those images are resized to various dimensions. I currently do that on my server, but was thinking of processing that on AWS or something similar. Is that a good idea? ...

Convert PHP Function to JavaScript

<?php function toconv(string) { $gogo = array("a" => "b","cd" => "e"); $string = str_replace( array_keys( $gogo ), array_values( $gogo ), $string ); return $string; } ?> How can I implement that in JavaScript? ...

Is there a difference between is_int() and ctype_digit()?

Is one more preferred, or performs better over the other? ...

In PHP, how do I send a control character down a socket?

In a PHP script I am writing, I need to send a control+z character down a network socket I have previously created. I understand the ctrl+z character to be chr(26), so at the end of the string I am sending I have added a new line (\r\n) and then the chr(26) as follows: $socket=fsockopen($host['host'],$host['port']); fputs($socket, "I am...

What are the arguments IN FAVOR of PHP closing tags for PHP only files?

The Zend Framework coding standard mentions the following: For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response. Zend Framework coding standard: file formatting However I do remember hea...

PHP: destructor vs register_shutdown_function

I have a PHP class that creates a PNG image on the fly and sends it to browser. PHP manual says that I need to make sure that imagedestroy function is called at end to release the memory. Now, if I weren't using a class, I would have some code like this: function shutdown_func() { global $img; if ($img) imagedestroy($im...

Is there identicon library for PHP

I'm looking for a PHP library/function/class which can create Identicons. ...

php: open_basedir and /dev/urandom

Calling the Pear Mail class in some instances automatically attempts to read /dev/urandom, however access is restricted due to an open_basedir setting. Is it safe to add /dev to open_basedir? Or is there a better way around this? ...

PHP's sleep function and client connections

How does PHP handle client connection while doing sleeps? Or put another way ... what happens if the client closes the connection to the server while a page is being processed? Does it just kill the process, or does it continue to process the page until the end? Since I'm not sure of the answers to the above how would I implement the ...

Parsing CSS by regex

I'm creating a CSS editor and am trying to create a regular expression that can get data from a CSS document. This regex works if I have one property but I can't get it to work for all properties. I'm using preg/perl syntax in PHP. Regex (?<selector>[A-Za-z]+[\s]*)[\s]*{[\s]*((?<properties>[A-Za-z0-9-_]+)[\s]*:[\s]*(?<values>[A-Za-z0-9...