php

if a php class is defined as final, does it make sense to define it's methods as final as well?

I have a class defined as final. Does it make sense to define the methods as final as well? I know that since the class itself is final it can't be extended, which would make the method final declarations redundant, but I want to work up documentation on the class and others, and thought it'd be help since the final property of the metho...

PHP DOMDocument, finding specific tags

I'm looking to find a specific attribute of a specific tag in an HTML document using PHP DOMDocument. Specifically, there is a div with a unique class set, and only a single span inside of it. I need to retrieve the style attribute of that span tag. Example: <div class="uniqueClass"><span style="text-align: center;" /></div> For th...

Validating a date with symfony using sfValidatorSchema

I'm using the following widget to allow a user to input a date $this->widgetSchema['first_registration'] = new sfWidgetFormDate(array( 'format' => '%month%/%year%', 'years' => range(date('Y', time()) - 15, date('Y', time()) + 15) )); The default format for a date using this widget is %month%/%day%/%year% and so that's what the def...

PHP Function Help

I've written this piece of code, which outputs the profile_display_fields for the $USER: $appearance = profile_display_fields($USER->id); if (empty($appearance)) { //Do nothing } else { foreach ($appearance as $c) { $custom .= '<a href=\''.$CFG->wwwroot.'/course/view.php?id='.$c->id.'\...

HEREDOC interfering with code indentation

I like the HEREDOC syntax, e.g. for edge cases of generated HTML that are not worth putting into a template. The only thing that annoys me about it, though, is that the content, and the closing marker of a heredoc string adheres to the first column. This screws up nested code layouts: class myclass { function __construct() ...

Select from Array to get ID based on Name

Here is my var_dump: array(2) { [1]=> object(stdClass)#382 (3) { ["name"]=> string(12) "Other fields" ["sortorder"]=> string(1) "1" ["id"]=> int(1) } [3]=> object(stdClass)#381 (3) { ["name"]=> string(6) "custom" ["sortorder"]=> string(1) "2" ["id"]=> int(3) } } I need some P...

In PHP, how do I add 3 months to the purchase date retrieved from the iPhone InApp receipt?

After I have validated the receipt against the App Store from my PHP server, the App Store sends me back a JSON response with "status" : 0 "receipt" : ( .... ) One of the receipt items is "purchase_date" which contains the following string (example) "2010-02-09 19:17:04 Etc/GMT" I'm trying to establish a subscription service and wou...

PHP Left Shift giving two answers on two different machines

Hello, I'm very confused about behaviour of PHP's left shift function. I'm using it on two different machines (dev and hosting), and they are giving me different answers. I've tracked it down to this calculation: (-3941404251) << 5; On one machine I'm getting the answer -1570884448; on the other, I get 0. On both systems, PHP_INT_MAX ...

How to enable HTTPS stream wrappers

I installed php5 on my windows system and tried to execute the following script with a command-line console: <?php // load in credentials $creds = parse_ini_file('/etc/aws.conf'); // Define query string keys/values $params = array( 'Action' => 'DescribeAvailabilityZones', 'AWSAccessKeyId' => $creds['access_key'], 'Timestamp...

Good books in Facebook development for beginner?

I found this question http://stackoverflow.com/questions/454051/good-resources-on-facebook-programming, but it haven't solved my problem. I'm new to facebook development, and also new to PHP & Javascript (Facebook Apps use these languages, yes? I have some experience in C#/.NET, it would be great if I can use them). I need some "basic" ...

How to use PHPdoc in Eclipse

We are currently in the beginning of a new project, and would like to (for once) comment as much as possible from the start to help future development. I have tried to find out what best practices are of using phpDoc in Eclipse, but with pretty slim results. Can you share your best practices and tricks of using phpDoc to comment stuff ...

PHP: What is the flow of control for error handling?

I'm new to PHP so I apologize if this seems silly. I've searched around and couldn't find anything that explained specifically what I'm looking for. Ultimately I have two goals. In production, when an unexpected error occurs, show the user a default "oops" page. When an expected error occurs, handle it without PHP dying. My mental ...

How to limit file upload speed in php or apache?

I'm doing some form in Zend Framework for file upload on "Apache friends - xampp" server 1.7.1 on Ubuntu 9.10. My problem is that I what to add progress bar for this upload and since xampp server is on my localhost, file uploads are very fast. As a result, I have no time to check or observer if progress bar works as it should. Is th...

PHP XML manager/Xquery creator?

Hi, i'm looking for a PHP solution to easily traverse (readonly) XML files (rss feeds) from websites. Other providers have XML feeds with different markups and I want to have an easy PHP (possible self-built) manager to just enter an URI and then immediately be able to 'select' nodes/attributes/nodegroups to create somesort of definitio...

Asynchronous web upload

Can anyone recommend a free module that will let me create web forms that allow asynchronous file uploads? I want to be able to upload files on a website without doing a full page reload. The module must work with a LAMP web site. The module can be built in AJAX or Flash. Or is it better for me to create this module myself? ...

array as session variable.

Is it possible to make an array a session variable in php. The situation is I've a table(page 1) with some cells having a link to particular page. The next page will have a list of names(page 2 which I want to keep in session array) with their respective check box. on submitting this form which will lead to transaction page(page 3 here v...

PHP's cURL: How to connect over HTTPS?

I need to do a simple GET request to EC2 Query API with regular URL encoded query string. The protocol is HTTPS. How would I send the request with the help of PHP's cURL. ...

Wordpress [caption] processing

I'm using a wordpress backend on my site and displaying the articles via my own way on the front end. I can't seem to find the file that parses the output of posts. I'm trying to get to the code that process a post so that I can copy it for my site and make some minor changes to how it's displayed on my site. Any ideas on where this f...

PHP Trim first 5 characters + semi-colon

Here is my string: usercss:body background: red, #header: background: #fff; I want to remove usercss: body background: red, #header: background: #fff; Then explode by , (comma) to produce a list like so: body { background: red; } #header { background: #fff; } Might be tricky to get the curly brackets in {} but if somebody could ...

restart pc using php

Is it possible to restart the pc using php? ...