php

PHP templates - with PHP

Hi, What's the most elegant templating (preferably in pure PHP!) solution you've seen? Specifically i'm interested in handling: Detecting in a repeating block whether it's the first or last element Easy handling of odd/even cases, like a zebra striped table, or similar Other modulos logic, where you'd do something every n'th time. ...

How do I transfer a file using wininet that is readable by a php script?

I would like to transfer a text file to a webserver using wininet as if the file was being transferred using a web form that posts the file to the server. Based on answers I've received I've tried the following code: static TCHAR hdrs[] = "Content-Type: multipart/form-data\nContent-Length: 25"; static TCHAR frmdata[] = "file=filename...

Is it possible to add data members dynamically in PHP?

I'm wondering if its possible to add new class data members at run-time in PHP? ...

Kablammo! Explode function giving me a headache!

$array = explode(".", $row[copy]); $a = $array.length -1; I want to return the last element of this array but all i get from this is -1. Help would be much appreciated. ...

CLOS like object model for PHP

I have returned to php development from Moose and I really miss CLOS like object model for php. Is there some kind of syntaxtic sugar which would allow me to write less code in php when dealing with objects? Just to stress this requirement a bit more. I don't want to write one thing in several places. I can live with part of code being ...

PHP 4 and 5, Ctrl-C, system(), and child processes.

I have a PHP script that uses the system() call to execute other (potentially long-running) programs (for interest: NCBI BLAST, phrap, primer3 and other programs for doing DNA sequence analysis and assembly). I'm running under Windows XP, using the CLI version of PHP from a command prompt, or as a service. (In either case I communicate ...

PHP Preserve scope when calling a function

I have a function that includes a file based on the string that gets passed to it i.e. the action variable from the query string. I use this for filtering purposes etc so people can't include files they shouldn't be able to and if the file doesn't exist a default file is loaded instead. The problem is that when the function runs and inc...

How can I access the raw HTTP request data with PHP/apache?

I was wondering if there was a way to get at the raw HTTP request data in PHP running on apache that doesn't involve using any additional extensions. I've seen the HTTP functions in the manual, but I don't have the option of installing an extension in my environment. While I can access the information from $_SERVER, I would like to see ...

What are some pros and cons of the various PHP IDEs?

This isn't a "Which IDE should I use?" question and I'm not interested in text editors no matter how awesome they may be (and I don't consider either vim or emacs to be an IDE so... unless you have a couple of days to explain precisely and in full gory detail how to fully configure, say vim, to work as a PHP IDE let's just stick to the b...

Determining Referer in PHP

What is the most reliable and secure way to determine what page either sent, or called (via AJAX), the current page. I don't want to use the $_SERVER['HTTP_REFERER'], because of the (lack of) reliability, and I need the page being called to only come from requests originating on my site. Edit: I am looking to verify that a script that ...

Zend PHP5 Certification, does it matter?

The Zend PHP5-certification, is it really worth it? In the end for me it boils down to: Will it get me jobs I wouldn't without it? ...

What's quicker; including another file or querying a MySQL database in PHP?

In PHP, which is quicker; using include('somefile.php') or querying a MySQL database with a simple SELECT query to get the same information? For example, say you had a JavaScript autocomplete search field which needed 3,000 terms to match against. Is it quicker to read those terms in from another file using include or to read them from ...

PHP - Custom error handling. Redirected 404 is being hijacked by AVG Anti-Virus. How to stop?

I have a website which uses the custom 404 error handling in PHP/Apache to display specific pages. e.g. http://metachat.org/recent I've a feeling this is a bad way of doing this, but it's code I inherited... Although the page displays correctly on most browsers, I'm getting a situation where AVG Anti-Virus is hijacking the page and re...

PHP Array, key without an assigned value

I am currently plowing my way through IBM's tutorial on CakePHP At one point I run into this snippet of code: <?php class Dealer extends AppModel { var $name = 'Dealer'; var $hasMany = array ('Product' => array( 'className' => 'Product', 'conditions'=>, // is this allowed? 'order'=>, // same thing here 'foreignKey'=>'dealer_id') ); } ?...

PHP utf8 problem

I have some problems comparing an array with Norwegian characters with a utf8 character. All characters except the special Norwegian characters(æ, ø, å) works fine. function isNorwegianChar($Char) { $aNorwegianChars = array('a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K',...

How to get Selenium working with PHP/Firefox3 on Linux

I am trying to get Selenium RC working with Firefox 3 on Linux with PHP/Apache but am experiencing problems. Here's what I've done: I have installed the Firefox Selenium-IDE extension. On the web server (which in my case is actually the same machine running Firefox), I've started the Selenium server with: java -jar selenium-server.jar...

Calling Python in PHP

I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac. I don't want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system() or popen() from PHP to call the Python...

Design patterns with PHP

Does anyone have any good book recommendations on design patterns, and applying them in PHP? ...

How do I limit which countries can view my website ( PHP )

In there an easy way to do this in PHP. I want to make sure that only web requests from certain countries are able to access my website. Any ideas? ...

PHP Module for reading torrent files

Is there a PHP module that you can use to programmatically read a torrent to find out information about it, Seeders for instance? ...