php

Ending php sessions for debugging purposes

Hi, This might be very easy to do, but I haven't been able to figure it out. Basically, I have a loosely couple web-app written in python and php. The python code uses PHP sessions (generated from the PHP app when the user logs in) to check if the user is logged in/has permission to access the given python resource. My question is thi...

What is the difference between is_a and instanceof?

I am aware that instanceof is an operator and that is_a is a method. Is the method slower in performance? What would you prefer to use? ...

Class inheritance in PHP 5.2: Overriding static variable in extension class?

Hi, I need to bea be able to use a static variable set in a class that extends a base class... from the base class. Consider this: class Animal { public static $color = 'black'; public static function get_color() { return self::$color; } } class Dog extends Animal { public static $color = 'brown'; } echo...

Getting a variable from an object with a string in PHP

I have a Persons object. It has a variable name accessible by saying $p = new Person('John'); echo $p->name; Now I have a string. $name = 'name'; I need to get $p->name using $p and $name. Something like echo $p->[$name]; ...

How can I tag a user in a photo using the Facebook Graph API?

I tried: $args = array( 'access_token' => $access_token, 'id' => $uid ); $url = "https://graph.facebook.com/{$idPhoto}/tags"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOP...

How to extracting individual dimensions from $node->content['dimensions'] in Drupal's Ubercart?

On my Ubercart node-product.tpl.php page, I am trying to extract the individual product dimensions (height, weight, length) from the more generic: print $node->content['dimensions'] ['#value']; which returns "Dimensions: 72in. × 42in. × 30in." Using var_dump(get_defined_vars()); I'm able to see that the dimensions are being outputted in...

Malformed XML when generating RSS with PHP DOMDocument

I am trying to generate a Google Merchant RSS Feed, using PHP's SimpleXML and DOMDocument. The actual generating code goes like that: $dom = new DOMDocument('1.0', 'utf-8'); $dom->formatOutput = true; $pRSS = $dom->createElement('rss'); $pRSS->setAttribute('version', '2.0'); $pRSS->setAttribute('xmlns:g', 'http://base.google.com/ns/1....

Passing parameters to Javascript using PHP

I have the following line of code: <a href="javascript:;" onClick="tweeet('myid')">My Tweets!</a> Now while this is working perfectly fine the following line is not: <a href="javascript:;" onClick="tweeet(<?php echo 'myid'; ?>)">My Tweets!</a> Can anyone help me out why it is not working and suggest any changes? The variable I wan...

Removing the cache of a contextual partial in Symfony 1.4

I've stumbled recently upon a problem. I have several partial which are in several actions and have different way of displaying data, hence I used the contextual option in cache.yml as such : _list: enabled: true contextual: true Now I needed to remove the partial cache when the data was updated, which is normally pretty easy when...

PHP preg_match: a pattern which satisfies all MySQL field names (including 'table.field' formations)

i need a pattern which satisfies mysql field names, but also with the option of having a table name before it examples: mytable.myfield myfield my4732894__7289FiEld here's what i tried: $pattern = "/^[a-zA-Z0-9_]*?[\.[a-zA-Z0-9_]]?$/"; this worked for what i needed before, which was just the field name: $pattern = "/^[a-zA-Z0-9_]...

PHP: How to get creation date from uploaded file?

Problem: I want to determine the original file creation time from a file uploaded to my server via PHP. My understanding is that the file is copied from the client to a temporary file on my server, which then is referenced in the $_FILES var. The temporary file is of course of no use because it was just created. Is there any way I coul...

Open zip file with bad header using php

I have a zip file that is uploaded to my server daily. It seems that this zip file isn't formed properly because when I open it with my IZarc (my desktop zip application) it warns me that there is a bad zip header found. I can go ahead and open the file if I tell IZarc to go ahead and open it. When I attempt to open the file with PHP li...

Explain this PHP shorthand

Possible Duplicate: What is the PHP ? : operator called and what does it do? I feed like a goof but I don't entirely understand what's happening in this code: $var .= ($one || $two) ? function_one( $one, $another) : function_two( $two, $another); Does that say if $one or $two then $var is equal to fuction_one(), else functi...

PHP cURL error: "Empty reply from server"

All, I have a class function to interface with the RESTful API for Last.FM - its purpose is to grab the most recent tracks for my user. Here it is: private static $base_url = 'http://ws.audioscrobbler.com/2.0/'; public static function getTopTracks($options = array()) { $options = array_merge(array( 'user' => 'bachya', 'peri...

Send email with PHP script -> How to display mutated vowels?

I use this php script to send an email. It works well, but german mutated vowels (ö,ä,ü, etc) are not displayed correctly. Any hints how to change that? <?php /* Geben Sie hier Ihre E-Mail Adresse zwischen den beiden " an: */ $_emails[0] = "[email protected]"; // Wenn keine $_POST Daten übermittelt wurden, dann abbrechen if(!isset...

Why am I getting a "skipping broken view error" ?

This is Drupal 6.x and am having a nightmare of a time to modify a simple drupal form. This is a module file. function modulename_menu() { $items = array(); $items['school/registration'] = array( 'title' => 'Registration Form', 'page callback' =>'drupal_get_form', 'type' => MENU_CALLBACK ); return $items; }...

PHP post request to retrieve JSON

I'm trying to write some simple php code that will make a post request and then retrieve a JSON result from the server. It seemed simple to me, but the below code simply doesn't open a connection. $port = 2057; $path = "/validate/"; $request = "value1=somevalue&value2=somevalue&value3=somevalue"; $http_request = "POST $path HTTP/1.0\...

Getting the first URL of an image search result with google image API in PHP

Hello, did you know a php script (a class will be nice) who get the url of the first image result of a google api image search? Thanks Example. <?php echo(geturl("searchterm")) ?> ...

FreshBooks API Libraries

I am new to FreshBooks (not only the API) and I want to use it for some automatically generated invoices. I was trying to run some of the source code examples (the PHP and JS libraries in particular): http://developers.freshbooks.com/api/samplecode/ The problem is that I get an error message: "Connection error" Do I need to set up anyt...

Why is Zend Framework (Zend_Db_table) rejecting this SQL Query?

I'm working on a simple JOIN of two tables (urls and companies). I am using this query call: print $this->_db->select()->from(array('u' => 'urls'), array('id', 'url', 'company_id')) ->join(array('c' => 'companies'), 'u.company_id = c.id'); whic...