php5

PHP: String formatting with printf

I am trying to write a quick string formatting routine to take an unformatted ISRC code and add hyphenation where it is required. For example, the ISRC USMTD9203901 should translate to US-MTD-92-03901. The pattern is: [A-Z]{2}-[A-Z]{3}-[0-9]{2}-[0-9]{5} I have been trying to implement this with substr and this has produced the follow...

Good Training Sources for OOP PHP, Anyone ?

Hey Guys. I will like to see if everybody could share any good training sources on OOP on PHP language. Good Training Sources for OOP (Object Oriented Programming) PHP, anyone ? I've seen numerous tutorials, mostly superficial, some of them bad. Please share anything good either commercial or free, Video or Written. ...

How to acess multiple classes through one parent class in PHP

Lets say I have a class called PageBuilder which I instantiate, send parameters to and call functions from through my index file (which acts as a front controller). There are three sub classes associated with the PageBuilder class: Head, Body and Foot, that are accessed by PageBuilder which basically abstracts them for index. So in the...

[SQL] How do I group by month and year when only having a datetime field?

I have a table schema which is essentially a bunch of transaction info with a datetime field TRANSACTION (< transactionid >, amount, when) I need to generate a monthly total of transactions, which is SUM(amount), but I stumped by what do I group by. Each row from SQL should contain the monthly total (so one row for Jan 09, Feb 09....J...

How to use external variables (e.g. POST/GET) in PHP with error level E_NOTICE

...

php 301 redirects actually doing a 302 redirect

I have been googling for this but no one appears to have the answer. This post describes the problem well: http://www.mail-archive.com/[email protected]/msg198576.html Server is Windows 2008 FastCGI PHP 5 Anyone solved this problem? ...

Error pointing to "line 0" in PHP.

Using PHP 5.3.0. I know you can get errors pointing to line 0 when executing code from the shell (with php -a or php -r). I also know you can get line 0 errors when an exception is thrown during the process of executing a custom exception handler. These are logical reasons why PHP might not be able to provide me with a line number for a...

SSL and php logins

Hai all, i successful configured a self signed SSL certificate and configure it in the MAMP server, now if i type https://localhost:443/ it will show the certificate, now i would like to configure a httpsdocs (like htdocs) and implement a secure login, can any one help me to run a simple page using SSL ...

What version is 5.2.0-8+etch13 really?

It is probably and stupid question, but what version of PHP5 is 5.2.0-8+etch13 ? Is it really 5.2.0 ? Because maybe it is just the debian version that covers something else. ...

upgrade PHP 5 on Plesk 9.2.1

Hi. I have Parallels Plesk 9.2.1, Debian 4 and 5.2.0-8+etch13 Is it safe to upgrade PHP5 to the latest version and how do I do it - I mean is there something special I have to be aware of? ...

PHP is displaying my source code?

I just upgraded to php5.3 and when I execute: php myfile.php I see the source code for myfile.php. Any idea why this is happening? I've never seen anything like it before! G-Man ...

Memory leak in transition from PHP 4 to 5 - any hints?

I am porting a large web application to a shared web hosting environment. The app was written in PHP 4. The new environment has PHP 5.2. For some reason, the application is leaking tremendous amounts of memory when running in PHP 5.2. I can literally watch memory usage going through the roof using memory_get_usage(), until it reaches ...

Undeclare a class in PHP

I have a daemon processing quite a bit of MVC logic in the background that includes the classes it needs on demand. Sometimes, however, it comes to a point where it includes two identically named classes from different modules within one cycle. Ideally, I would like to "undeclare" a class before I include it again, I cannot find in the P...

gmail to sms from my application

Hi there Does anyone know how can i send a sms messsage when e-mails are arriving in a gmail account? I know some PHP, C/C++ and C#, and I plan to read the new message using POP3. The problem is that I don't know how can I send a SMS message to a mobile phone. Do I need a SMS server? can you give me some advices? ...

Google MAP HTTP request or API

Hello All, I would like to get driving time information from one location to another using google maps. I have found another fantastic post on this site here Although the above link is based on geo codes I woud like to use zip codes if possible. But I really like to get the time via a php call as this time is being worked out in the ...

mime magic php question

Hi, I understand mime_type is deprecated and should use fileinfo instead. My question is, do I still need to enable mime magic on php. M ...

PHP Regex remove unwanted data

Hi All I would like to be able to remove content from a string of data. This is an example string from google maps api. Distance: 70.5&#160;mi (about 1 hour 12 mins)<br/>Map data &#169;2009 Google I would like everything in between the brackets (). So can I remove everything from either side with preg_split ? Hope you can advise. ...

php5 extend main class and use statics

why I can't do like this? <?php class core { public static $db; function __construct() { $this->db = new mysql('host', 'user', 'pw', 'db'); } } class stat extends core { public static function log() { core::$db->query("insert into mytable values(now())"); } } // do something stat::log(); ?> ...

PHP sessions: What if I set the session expiry to 10 days?

I want the users of my application to stay logged in for very long periods of time. The problem is the the session expires on the server end, thus losing variables stored in the session. So, I'm setting the session to expire in 10 days. My question is: Is there any security or performance issues of setting the GC expiry and cookie lifet...

Why is PHP not seeing my query string?

This phpinfo() demonstrates the problem. I'm passing the URL a query string of: ?qwerty=asdfg As a result, I'm expecting it to list these two PHP variables: _REQUEST["qwerty"] asdfg _GET["qwerty"] asdfg And also this query string: _SERVER["QUERY_STRING"] qwerty=asdfg However, it's not working. None of these variables seem to be...