php

Is using a Mail Model in MVC incorrect?

I have built a model in some of my MVC websites to assist with sending emails, generally I do something like this $mail = new Mail_Model; $mail->to('[email protected]'); $mail->from('[email protected]'); $mail->subject('hello'); $mail->body('hello how are you'); $mail->send(); I know the model is meant to model data - so is what I'm do...

Problem with running the Nutch command from PHP exec()

My Nutch directory lies in /home/myserv/nutch/nutch-1.0/ My php applictaion is in the diretcory /home/myserv/www/ Theres a a php file in my /home/myserv/www/ diretcory that runs a exec command to run a nutch command.PHP code is like : $output = exec("bin/nutch all"); When I run the command from the command line I need to be in th...

php session help

Ok so my main page has a session. I am using the session id to query the database. Now when I post to a page I have session_start() at the top but when I echo the session_id() on the main page and on the page that was posted to they are 2 different values. Why is it changing the session_id()? Is there a way to make it keep the original...

Help with changing how jWYSIWYG editor works

In jWYSIWYG editor, pushing enter inserts <br />s. Instead of this, I would prefer that pushing enter would wrap chunks in <p> tags. WHAT IS OUTPUT line <br /> new line WHAT I WANT <p>line</p> <p>new line</p> Quick examination of the config seems I can't do it without hacking it internally. Do you suggest I hack the plugin, or u...

What's the difference between !== and != in PHP?

Possible Duplicate: php == vs === operator What's the difference between !== and != in PHP? ...

Is it possible to modify methods of an object instance using reflection

What I'm trying to do is create a domain model with a Plain Old PHP Object. The I'm creating a library which will do all the infrastructure stuff. So one of my models looks like this class Project { public $id; public $name; public $typeId; private $type; public function getType() { return $this->type; } public func...

How do I make 15 static PHP classes work together well?

I have a personal PHP application that has about 15 classes. Each class is only initiated once as a page is executed. In other words, when the page loads: 15 classes are loaded, and as each class file gets loaded, I create one instance of the class. The application (so far) is designed so every variable in the system has one state duri...

Controller folders and the new Autoloader in Zend Framework

After introduction of Autoloader, I started to port existing ZF app. The immediate error was that IndexController was extended by BaseController, which is now cannot be found, although it resides in application/controllers folder, with other controllers. Does the autoloader paradigm require that BaseController is renamed to My_BaseContr...

To create check box in symfony using widgets and also validate it?

the code in symfony that i am using, $this->setWidgets(array( 'mobile' =>new sfWidgetFormInput(), 'subscribetosms' =>new sfWidgetFormInputCheckbox(), )); i want to validate the checkbox, and also code to take values from check box ...

For loop in while loop

Hi, can I put a for loop in while loop? For example: while($end = 1) { for ($i = 0; $i < count($match); $i++) { $mathcas = $match[$i][1]; } } Thanks. :) ...

implementing firephp

that's about it...the problem is I want to make firephp work, but I can't find any simple examples! What's it for anyway? "FirePHP enables you to print to your Firebug Console using a simple PHP function call." Why would I want to do that anyway? Are there any solid debugging advantage in using FirePHP? ...

download multiple files as zip in php

How to download multiple files as zip in php? ...

How to check if there are only spaces in string in PHP?

print_r(strlen(trim(' '))); the result is 9 I also tried preg_replace('/[\n\r\t\s]/', '', ' ') but the result is not zero. Please download my code and you will get the result http://blog.eood.cn/attachment.php?id=70 ...

Where do I have to use the & operator in PHP?

A few years ago I used to work with PHP and there've been many changes in PHP, especially on the OOP part. Back then it was necessary to use the & operator at several places, especially when working with object instances (OOP was very rudimentary then) to avoid copying object instances. With PHP 5.2 there seems to be a lot of improvem...

PHP: A better way of getting the first value in an array if it's present.

Here's my code: $quizId = ''; foreach ($module['QuizListing'] as $quizListing) { if ($quizListing['id']) { $quizId = $quizListing['id']; break; } } Is there a better way of doing this? ...

A problem with access permission and file path in php

Hello, I use a index.php to control the access of pages. Here is the mechanism: Index.php redirects the page to search.php; code: index.php/?page=search the path of search.php is : pages/search.php, search.php includes header.html, body.html etc. Now in body.html we call search.php using: index.php/?page=search parameter, and b...

Why are the commas in my array reading as a string?

This is what I am trying to do: 1 - I have an array with a string. $photographer_array = "'Alberto Korda', 'Annie Leibowitz', 'Ansel Adams'"; 2 - I am trying to populate an array with that string. array($photographer_array); What it is doing is creating an array with one single entry including all the commas. Why is it reading the...

Prevent file differences between live and staging websites AND system scripts (PHP)

I'm trying to find a good way to maintain PHP configuration differences between a dev and live environment. I know how to handle differences when scripts are run by Apache (see below), but not when they are run on the command line, e.g. via cron. Background info: What do I mean by "configuration differences"? Like most code shops, we r...

Serve a large file via Zend Framework

In our application, authentication is handled via set of Controller Plugins that validate the user etc. I want to serve a large (video) file only to authenticated users- the obvious way to do this is via readfile() in the controller, but I'm finding it hits the PHP memory limit - presumably the output from the controller is buffered som...

Is there any good book or website where I can learn php regular expressions?

Any recommendations, as I need to learn regular expressions to search for specific string and replace using specific operators. I have looked at the php functions such as preg_match && preg_replace and understood how they work but all I need is to be more familiar with the operators for expressions. Thanks. ...