php

Best practices for withstanding launch day traffic burst

We are working on a website for a client that (for once) is expected to get a fair amount of traffic on day one. There are press releases, people are blogging about it, etc. I am a little concerned that we're going to fall flat on our face on day one. What are the main things you would look at to ensure (in advance without real traffic d...

Whats the best book/site/tutorial for learning object oriented php?

Im pretty familiar with procedural side of php, but I would like to learn the OO side of things. Can you guys suggest some (short) reads that would get me on my way? Would prefer online articles, to paper. ...

Replace one URL with another

In PHP, replace one URL with another within a string e.g. New post on the site <a href="http://stackoverflow.com/xyz1"&gt;http://stackoverflow.com/xyz1&lt;/a&gt;&lt;/p&gt; becomes: New post on the site <a href="http://yahoo.com/abc1"&gt;http://yahoo.com/abc1&lt;/a&gt;&lt;/p&gt; Must work for repeating strings as above. Appreciate ...

Python Regex vs PHP Regex

No not a competition, it is instead me trying to find why a certain regex works in one but not the other. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) That's my Regex and I'm trying to run it on 127.255.0.0 Using Python...

Convert a UTF-8 string to/from 7-bit XML in PHP

How can UTF-8 strings (i.e. 8-bit string) be converted to/from XML-compatible 7-bit strings (i.e. printable ASCII with numeric entities)? i.e. an encode() function such that: encode("“£”") -> "&#8220;&#163;&#8221;" decode() would also be useful: decode("&#8220;&#163;&#8221;") -> "“£”" PHP's htmlenties()/html_entity_decode() pair d...

Set up Apache for local development/testing?

I've been impressed by the screencasts for Rails that demonstrate the built-in web server and database to allow development and testing to occur on the local machine. How can I get an instance of Apache to execute a project directory as its DocumentRoot, and maybe serve up the files on port 8080 (or something similar)? The reason why I'...

Stored Procedures, mySQL and PHP5

The question is a fairly open one. I've been using Stored Procs with MS SQLServer for some time with classic ASP and ASP.net and love them, lots. I do have a small amount of experience with PHP4 and mySQL, and previously when working with these was limited to in-line SQL. I have a small hobby project I'm working on and for various rea...

Lazy Function Definition in PHP - is it possible?

In JavaScript, you can use Lazy Function Definitions to optimize the 2nd - Nth call to a function by performing the expensive one-time operations only on the first call to the function. I'd like to do the same sort of thing in PHP 5, but redefining a function is not allowed, nor is overloading a function. Effectively what I'd like to d...

Best PHP IDE for Linux / Gnome ?

Hey, I'm on a continuous mission to find the ultimate PHP IDE that will work with Gnome on Linux. Let me know what you think. Thanks a million! ...

PHP unserialize keeps throwing same error over 100 times.

So I have a large 2d array that i serialize and base64_encode and throw into a database. On a different page I pull the array out and when I base64_decode the serialized array i can echo it out and it definitely looks valid. However, if i try to unserialize(base64_decode($serializedArray)) It just throws the same error to the point of ...

How do you copy a PHP object into a different object type

New class is a subclass of the original object It needs to be php4 compatible ...

What will break once PHP6 is released?

PHP6 haven't been released yet. But because of the majority of websites that uses PHP, once PHP6 is released, programmers would support that version. PHP6 can break code that works on PHP4 and PHP5. The purpose of this question is to have a nice list of what PHP programmers should be aware of before PHP6 is released. This can help PHP p...

PHP simplexml problem

I have the following XML structure: <?xml version="1.0" ?> <course xml:lang="nl"> <body> <item id="787900813228567" view="12000" title="0x|Beschrijving" engtitle="0x|Description"><![CDATA[Dit college leert studenten hoe ze een onderzoek kunn$ <item id="5453116633894965" view="12000" title="0x|Onderwijsvorm" engtitle="0x|Method...

PHP and MS Access Schema

I am using following PHP code to connect to MS Access database: $odb_conn = new COM("ADODB.Connection"); $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". $db_path.";"; $odb_conn->open($connstr); How can I retrieve database catalog/metadata from the mdb file? FOUND THE SOLUTION $rs_meta = $odb_conn->OpenSchema(20, array(N...

PHP: running scheduled jobs (cron jobs)

I have a site on my webhotel I would like to run some scheduled tasks on. What methods of achieving this would you recommend? What I’ve thought out so far is having a script included in the top of every page and then let this script check whether it’s time to run this job or not. This is just a quick example of what I was thinking abou...

How to sort an array of UTF-8 strings?

I currentyl have no clue on how to sort an array which contains UTF-8 encoded strings in PHP. The array comes from a LDAP server so sorting via a database (would be no problem) is no solution. The following does not work on my windows development machine (although I'd think that this should be at least a possible solution): $array=arra...

Is there a PHP security framework that protects phone numbers as well as passwords?

I understand the mantra of "don't roll your own" when it comes to site security frameworks. For most cases anyway. I'm going to be collaborating on a site that integrates text-messaging into the system. I'd like to use an existing, well-tested security framework to protect the users data, but I need it to also protect a users phone nu...

PHP: Use Pecl/Pear, or build my own systems?

When building some of my PHP apps, a lot of the functionality could be coded using PEAR/PECL modules, however, the fact that some people using it may not have the access to install things, It poses a puzzler for me. Should I forsake some users to use PEAR/PECL for functionality, where these will allow me to have a system coded up quicke...

MVC frameworks on hosted servers

Hi all This may seem like a daft question, but i was wondering about how to use MVC frameworks on hosted servers. I am playing about (albeit slowly) at home with the RoR on Ubuntu and understand that if i want to do a live site then i need hosting with Rails and Ruby. However, what happens about the PHP frameworks. For example i have ...

Pros and cons of using one file for entire webpage?

I'm not sure how I should express this, but I'll give it a try. I recently started coding my portfolio in object-oriented PHP and I'm wondering if it's according to best practices to use a single page where the content changes depending on SQL data and the $_GET variable? If so/not, why? Edit: Take a look at my next post, more in-dept...