php5

PHP anonymous function before 5.3 - array_walk

Hi, I need some help here.. Is it possible to use PHP array_walk with an anonymous function (before PHP 5.3)? or some workaround.. I'm using array_walk inside a public class method and I don't want to define a PHP function.. I want to do something like: array_walk($array, function($value) {...}); If that's not possible is it possibl...

PHP - How to check if Curl actually post/send request?

Hey, I basically created a script using Curl and PHP that sends data to the website e.g. host, port and time. Then it submits the data. How would I know if the Curl/PHP actually sent those data to the web pages? $fullcurl = "?host=".$host."&time=".$time."; Any ways to see if they actually sent the data to those URLs on My MYSQL? ...

require_once() [function.require]: Failed opening required '/vars.inc' (include_path='.;C:\php5\pear')

Hey, I have several sites setup on my local machine - customerappglobal, customerapp and naturaleigh. I have just one - customerappglobal - working at the moment because thats the only one I need working. I have added the following code to my httpd.conf file: <VirtualHost *:427> # The name to respond to ServerName customerappglobal ...

PHP json_encode as object after PHP array unset()

I'm experiencing odd behavior with json_encode after removing a numeric array key with unset. The following code should make the problem clear. I've run it from both the CLI and as an Apache mod: PHP version info: C:\Users\usr\Desktop>php -v PHP 5.3.1 (cli) (built: Nov 20 2009 17:26:32) Copyright (c) 1997-2009 The PHP Group Zend Engine...

Has anyone here tried PHP On Pie?

I created this framework to fill what I felt was a need for a PHP-like framework that was really efficient. My goal is to make it into a real open-source project, but since I have never launched a popular open-source project, I could use some feedback and advice. My question is, has anyone here used it, and if so, what was your experien...

pdf download problem

hi to all i am using html2pdf class to generate pdf. in my problem its generate pdf for the html code but it not give the dialog box option to download that pdf. plz help my cose is following. ob_start(); include(dirname(__FILE__).'/res/pdf_demo.php'); $content = ob_get_clean(); // conversion HTML => PDF require_once(dirname(__FIL...

how to test PUT request parsing in PHPUnit

Hello all, I'm parsing a PUT query this way : $raw = file_get_contents('php://input'); $params = array(); parse_str($raw, $params); and I'd like to inject some test content into php://input to test it (and for some non-unit tests too). I tried to google a bit the matter, but 'put' is a short keyword and I didn't get anything r...

Doctrine 2 get real class name of proxy class

The following: I have approximantely 20 models. These classes extend a base class. This base class contains a method which should be able to determine the classname of the child element. Normally you could this with: get_called_class(); But in many cases doctrine 2 uses ProxyClasses and in that case the get_called_class() function re...

Using Zend_Controller_Route to automatically determine the controller based on the user role: how?

I am currently figuring out a way to the the above. My current application structure is as follows: /modules / modulename /controllers /ProjectController.php The application has 3 different user roles, each with functionality contained within these modules. I'd like to prevent having multiple actions for each user role in one...

ADOdb Active Record Relation on a different database

Using ADOdb Active Record's One-to-Many relations, can I set a relation which use another database? Using "manual relations", I can load them whitout problem since each Model has it's own database prefix. ...

PHP 5.2 Error with static var: "syntax error, unexpected T_STATIC"

Hi, I have a pretty weird problem: My Class looks like this <?php class asd { private static $variable; public static function blabla(){ self::$variable="blubb"; } } ?> When I'm trying to call asd::blabla() with the help of the __autoload function, everything works fine. But when I'm trying to call it without a...

PHP static::DerivedClassName

Is there any way to get the Derived Class Name from static Keyword ? What I actually want to do is. Make a Reflection of the Derived Class Check Wheather it implements the Specified Class or not I've a static method the Base Class say its named Base::check() I want Base::check() will check for the existence of the Interface Implementat...

csv to excel conversion

Is there a way to convert csv file to excel file upon request through apache/.htaccess ...

Reason ForceType application/x-httpd-php on .htaccess not working at all

I have tried to use: .htaccess <Files client> ForceType application/x-httpd-php </Files> client file <?php echo "FOO BAR"; ?> Just to test, but the server is not parsing the client file, it just serves it up as a file download. I tried SetHandler also without luck. UPDATE I'm using MediaTemple and the have there own way o...

how to dice up the array

I have an array like this (below is the var_dump) array 0 => object(stdClass)[11] public 'VN' => string '571.5' (length=5) public 'color' => string 'GREEN' (length=5) public 'name' => string 'CIRRHOSIS' (length=9) public 'icd9ID' => string '5765' (length=4) public 'ID' => string '46741' (length=5) ...

Using backtrace_debug to determine caller class and caller method for the function. Am I doing it wrong?

I have a parent class and a children class. In a parent class I define a function f() and want to print in it name of children class that extended parent class and name of children method that called this function. I do it like that. abstract class ParentClass { public function f() { $backtrace = debug_backtrace(); ...

php strftime('%P') on osx gives P instead of pm with setlocale(LC_TIME, 'en_CA')

This code ... <?php setlocale(LC_TIME, 'en_CA'); $time = strtotime("07:00 PM"); echo strftime('%l:%M %P', $time); ?> provides this result on OSX 10.6.4 with stock PHP 5.3.2 or PHP 5.2.13 from macports: 7:00 P however I get the desired result on Ubuntu 9.10 with PHP 5.2.10: 7:00 pm Why the difference? How can I fix it? ...

Timezone offsets (and st/dst changes) in MySQL / PHP

Basically I have a site that allows stores to store their open/close times. Now, I'm trying to add the feature of giving their visitors the ability to see if the store is closed. I understand I can run a query like: SELECT * FROM `store_hours` WHERE TIME(NOW()) BETWEEN `opens` AND `closes` ... and the query works and retrieves the s...

how to use array_push when pushing both key and value in PHP.

Hi, I have an empty array. I am able to push values using array_push($list, item[0]); But how do I push both key and value. array_push($list[$key], $item[0]) this does not work. I appreciate any help. Thanks. ...

getting a variable from a public scope to connect database

<?php $settings['hostname'] = '127.0.0.1'; $settings['username'] = 'root'; $settings['password'] = 'root'; $settings['database'] = 'band'; $settings['dbdriver'] = 'mysql'; /** * DATABASE */ class database { protected $settings; function __construct() { } function connect() { $this->start = new PDO( $this->settings['dbd...