php

What can use for DateTime::diff() for PHP 5.2 ?

A quick question. Is there any function equivalent to DateTime::diff() in php 5.2? My local server is php 5.3 and using DateTime::diff(). then I found that my live site uses php 5.2 and gives an error. Fatal error: Call to undefined method DateTime::diff() in /var/www/some/other/dir/web/daikon/modules/projects/views/admin/log/admin_lo...

converting string containing keys and values into array

does anyone know an elagant way of turning this string (the list is not definite.. the "keys" and "values" can be added arbitrarily) business_type,cafe|business_type_plural,cafes|sample_tag,couch|business_name,couch cafe into this array? array( [business_type]=>'cafe' [business_type_plural] => 'cafes' [sample_tag]=>'co...

Feeding multi-line string value to jquery methods

How do I feed string variable holding multiline value in it to jquery method like prepend? I need it to construct a form pass by drupal search module like - $('#divsearch').prepend('<?php print $search_box; ?>'). Thanks a bunch. ...

Accessing an ArrayAccess item directly

I'm trying to get an item of an array by its key. The array is in fact a SolrObject, which implements ArrayAccess, so I understand that I can access its items as I would in an array. This is the structure of my $myobject: SolrObject Object ( [116809] => SolrObject Object ( [title] => Array ( [0] => F...

Zend redirecting What's the difference between these 2 ways

Is there any real difference between $this->_redirect('controller/action'); and $request->setControllerName('controller') ->setActionName('action'); My guess is that the first one maybe uses the second one behind the scenes. Does anyone know? ...

PHP session variable security

Is it a bad idea to store a raw sql query in a php session variable for later use? Does this present any security issues? ...

TextArea line breaks for e-mail

How can I take the text from a textarea (html) and insert line breaks. Right now, if I input info to send out as an e-mail, it puts all the text on the same line without any line breaks. Using $_POST['field'] to get the data from the form and sending using PHP mail. ...

PHP- Ajax and Redirect

i have a jquery Ajax request happening on a page. On php side i am checking if the session is active and doing something. If the session is not active i want to redirect the user to another page in php(header redirect). how do i do it. I know how to achieve it in javascript(i.e if session_fail then change window.location but is there...

PHP front-end for installing Django

A simple question: Is this possible? Is it worth the time looking into it? ...

Can a web server login to external app and pass the cookie to user's browser?

I'm trying to implement single sign-on for a web portal. I've written some code to send a POST request containing the user's login credentials to an external web app to log the user in. (Don't worry, this is all over SSL) The HTTP response from the web app contains a cookie for the user's login. Is it possible for the web portal serve...

PHP - How can we call this symbol: -> ? And this one => ?

Possible Duplicates: Reference - What does this symbol mean in PHP? In, PHP, what is the -> operator called and how do you say it when reading code out loud? What does '=>' sign in php means? Wondering how can we call this symbols. -> and => :) Ps- I know this one :: :D ...

What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?

I am developing a social networking website in the facebook/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks. ...

php constants and EOT

is it possible to display constants php's EOT? for example: <? define('Hey', "HellO"); echo <<<EOT Hey EOT; ?> ...

how to test if PHP system() function is allowed? and not turned off for security reasons

Hi! I would like to know how to test if system() or exec() is allowed on a server. I keep getting this error "Warning: exec() has been disabled for security reasons in ..." I understand that the safe_mode function is depreciated in the php version my provider runs (5.3.3) so i cant use a get_ini('safe_mode') check. What else to do? I...

PHP: Making time limit

Hello. Im using ajax call to insertmsg.php to insert a message. Now javascript isn't a realtime language so i can not count on having an disabling button at the top of the ajax function. So I wonder how I can make a timelimit to the insertmsg.php with: mysql_query("INSERT INTO.. , with a delay on 2 seconds, without storing last time t...

Convert ASP code using Chr(13) to PHP

Hi, I am trying to move a old Classic ASP site to run in PHP. I am rewriting bits of it, however I have come across the following function that is causing me some problems. Basically the function FixForSQL is run on everything before adding it to the database and then FixForHTML is run on data returned with a SQL query to format it for d...

How can i differentiate LAN computers in php

Hello, I want to find each LAN connected computer separately. I am fetching ip address but i am assuming if many computers are connected to LAN they may give same ip.How can i differentiate all computers separately in php ? ...

Structure of php JSON output

this is continued from another question i asked: http://stackoverflow.com/questions/4033116/listing-out-json-data my search only returns 1 item, im pretty sure the problem lies somewhere in my php, im not too sure if im adding to the array properly, or it could be the javascript wich you can see on the above link, but i doubt it. my ph...

php $_POST and pagination $_GET

Hello, I face a problem whenever the user tries to browse to second page via $_GET if they have submitted $_POST data. if(!isset($_POST['submit'])) { //search input box } else { //search details output //pagination code } Whenever user press page 2, it shows //search input box back. I want search to show page 2 and not //search inpu...

What is this date format called and how do I parse it?

I have a weird date format in some files I'm parsing. Here are some examples: 1954203 2012320 2010270 The first four digits are the year and the next three digits are day of year. For example, the first date is the 203rd day of 1954, or 7/22/1954. My questions are: What's this date format called? Is there a pre-canned way to parse ...