php

Simultaneously uploading files to multiple ftp with php?

Hello, My application is uploading the same content to two storages. Firstly, application uploads files to the first ftp and then to another one. Is is possible to upload to both FTP simultaneously? Thank you ...

Error : execution time for the action exceeded .. secs. In PHP only on Linux.

Hi I am facing an Error : execution time for the action exceeded .. secs. In PHP. I am using set_time_limit(0); and it is working fine on windows. but it is not working on linux. what might be the reason? Thanks & Regards Rahul ...

file doesn't open using PHP fopen

i have tried this: <?php $fileip = fopen("test.txt","r"); ?> this should have opened the file in read only mood but it doesn't the test.txt file is in same folder as that of index.php (main project folder) the file doesn't open and when i put echo like : echo $fileip; it returned Resource id #3 ...

Pearson correlation in PHP

I'm trying to implement the calculation of correlation coefficient of people between two sets of data in php. I'm just trying to do the porting python script that can be found at this url http://answers.oreilly.com/topic/1066-how-to-find-similar-users-with-python/ my implementation is the following: class LB_Similarity_PearsonCorrelati...

php javascript ajax weird string error

I am building some html in a php script in order to send it back to a page via Ajax. $other_content = Model_Db::dbSelect($query); $div_center .= "<table>"; for($i = 0;$i<sizeof($other_content);$i++) { $div_center .= "<tr>"; $div_center .= "<td><a href='#' onclick='changediv('test','0')'>".$other...

What's the state of PHP unit testing frameworks in 2010?

As far as I can see, PHPUnit is the only serious product in the field at the moment. It is widely used, is integrated into Continuous Integration suites like phpUnderControl, and well regarded. The thing is, I don't really like working with PHPUnit. I find it hard to set up (PEAR is the only officially supported installation method, and...

Why/how does joining arrays with + in PHP work?

I've noticed recently in PHP you can do this. $myNewArray = $oldArray + $someArray; This looks completely different to anything I've seen before involving manipulating arrays in PHP. How and why does it work? Are there any pitfalls? I have recently started using it in some places where I may have used array_unshift() and array_merge...

PHP: Turning multidimensional arrays to single dimension arrays

Hi, Basically my app is interacting with a web service that sends back a weird multidimensional array such as: Array ( [0] => Array ( [Price] => 1 ) [1] => Array ( [Size] => 7 ) [2] => Array ( [Type] => 2 ) ) That's not a problem, but the ...

Is it possible to access outer local variable in PHP?

Is it possible to access outer local varialbe in a PHP sub-function? In below code, I want to access variable $l in inner function bar. Declaring $l as global $l in bar doesn't work. function foo() { $l = "xyz"; function bar() { echo $l; } bar(); } foo(); ...

MVC, DI (dependency injection) and creating Model instance from Controller

Hello, My Dispatcher is "choosing" correct Controller; then creating Controller's instance (DependencyInjectionContainer is passed to Controller constructor); then calling some Controller's method... class UserController extends Controller { public function __construct(DependencyInjectionContainer $injection) { $this->container ...

jquery text area problem

i have one text area <textarea name="message" id="message" class="text_field" style="height:200px; width:500px"></textarea> if i type data in the text area like this hello this is my test message bye 'abc' i use following statement to get data from text area var message = $('#message'...

Is it possible to format a number to 2 decimal places with Smarty PHP

Hi, Is it possible to format a number to 2 decimal places with Smarty PHP? Thanks. ...

PHP Path Problem

Hy everyone i have a problem with my path say i have a PHPfile in /home/bla/www/dev/source/test.php in this test.php i want to include a file in /home/bla/www/config/conf.php <?php include_once(""); ?> i dont want to include it like include /home/bla/www/config/conf.php How can i do it? PS. this fails include_once("../.....

ajax deleting first row from mysql list

i have a list of rows from my db with delete next to each row but ajax is always deleting the first row in the list no matter what. PHP CODE >>>>>> $allowedFunctions = array( 'add_job', 'get_log', 'delete' ); $functionName = $_GET[ 'func' ]; if( in_array( $functionName, $allowedFunctions ) && function_exists( $functionName )...

JavaScript return and php problem (true,false)

now i made JavaScript code (jquery code) and when i click ok it return true if i want true and false if i want false now the problem is php not consider true as php keyword true its just consider it a word like any other word and i must make it like this if($post == 'true') and i want make it like this if($post) // retuen true if $p...

Change php img resizer class to prevent upscaling/pixelating images (by adding whitespace)

Hi, I'm using this php class (http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php) for creating the different sized images that my website requires. I am using the resizeToWidth() method. Everything is great except for if I'm requesting an output-width greater than the original, then the image is upscaled and pixelate...

How to call the constructor with call_user_func_array in PHP

How could I call the constructor of a class with call_user_func_array It is not possible to do : $obj = new $class(); call_user_func_array(array($obj, '__construct'), $args); because if the constructor has parameters, the new will fail. Constraint : I do not control the classes that I have to instantiate, nor do I can modify them. ...

Downloading large number of Images to my Server and notifying the User when Download is finished.

Hi, I want to download a large amount of Files to my Server. I have a List of different Files to download and Locations where to put them. This all is not a Problem, i use wget to download the File, execute this with shell_exec $command = 'wget -b -O' . $filenameandpathtoput . ' ' . $submission['url']; shell_exec($command); This work...

Unit testing classes - is throwing errors out of the question?

I am getting my head around PHPUnit, and trying to build a test case for an existing class. The class is a static configuration class, getting, setting and listing configuration options that will be available in the application. The class is very strictly built. If I try to set a configuration setting with an incompatible value, or a c...

How does PHP track created objects?

This may be a bit of daft question, but I don't come from an OOP background and although I'm reading and learning as I go I'm still struggling with a few concepts. Right now I'm working with PHP 5.3 and desiging a fairly simple login using a few different object classes: User which defines the user. Session which starts and maintains s...