php

Techniques for writing a scalable website.

I am new in the website scalability realm. Can you suggest to me some the techniques for making a website scalable to a large number of users? ...

How to create a SSL connection in PHP with SO_KEEPALIVE?

I have some simple PHP code that creates a SSL connection $streamContext = stream_context_create(); stream_context_set_option($streamContext, 'ssl', 'local_cert', $this->sslPem); stream_context_set_option($streamContext, 'ssl', 'passphrase', $this->passPhrase); $this->apnsConnection = stream_socket_client('ssl://'.$this->apnsHost.':'.$...

xml validity, ajax, and php

Hello all. I'm returning some XML from PHP to Javascript via ajax and getting some 'invalid xml' errors. The xml I'm returning looks like this: <response> <song>tdb2009-01-29s2s06</song> <song>tdb2009-01-29s1s02</song> </response> And my javascript to parse it looks like: function u_handleServerR...

What's better: Json or XML (PHP)

I'm manipulating few data with PHP, I have the choice between Json and XML. But I don't know what to choose, I never worked with one of them. So I want the easiest one. Also I wonder if there's good classes that can make parsing (XML or Json) easier. I focus mainly on ease of use rather than speed and scale. ...

How do I strip data from HTML tags

Say I have data like this: <option value="abc" >Test - 123</option> <option value="def" >Test - 456</option> <option value="ghi" >Test - 789</option> Using PHP, how would I sort through the HTML tags, returning all text from within the option values. For instance, given the code above, I'd like to return 'Test - 123', 'Test - 456', '...

How can I convert a PHP upload-file script to Perl?

In PHP I have the following code that gets a file submitted through CGI: move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile) The file is being sent as Content-Disposition: form-data; name="userfile"; filename="filename" Content-Type: application/octet-stream The file being upload is of type PNG. How do I access the da...

html form submission in python and php is simple, can a novice do it in java?

I've made two versions of a script that submits a (https) web page form and collects the results. One version uses Snoopy.class in php, and the other uses urllib and urllib2 in python. Now I would like to make a java version. Snoopy makes the php version exceedingly easy to write, and it runs fine on my own (OS X) machine. But it alloca...

How do I read a text file into array of lines and display it using PHP?

I have text file that looks like this: 1 1 1 1 1 2 3 5 4 4 5 5 I want to read this text file into array of lines and display it. Can anyone help me do this? ...

A fail-safe way to prevent GD image library from running out of memory? (PHP)

Is there a way to prevent the PHP GD image library from running out of memory? If too large an image is uploaded, GD tends to run out of memory, terminating the script. I'd like it to throw a catchable exception or something to that extend, but alas it doesn't. Right now I'm using a cobbled-together script that first issues an ini_set('...

Eager loading vs. many queries with PHP, SQLite

I have an application that has an n+1 query problem, but when I implemented a way to load the data eagerly, I found absolutely no performance gain. I do use an identity map, so objects are only created once. Here's a benchmark of ~3000 objects. first query + first object creation: 0.00636100769043 sec. memory usage: 190008 bytes itera...

PHP gzcompress vs gzopen/gzwrite

I'm writing a PHP script that generates gzipped files. The approach I've been using is to build up a string in PHP and gzcompress() the string before writing it out to a file at the end of the script. Now I'm testing my script with larger files and running into memory allocation errors. It seems that the result string is becoming too la...

Help with htaccess RewriteRules

Hello, I am posting this question again because I didn't explain clear enough. Here are things that I need to achieve with the .htaccess file: Re-route /public_html/ to /public_html/myfolder/ Make website/index.php?q=param to website/param/ My php files are inside /public_html/myfolder/ and my image files are inside /public_html/myfol...

php local development, apache www directory permissions

I am interested in setting up a local php testing / development environment using the lamp stack. I would like to use the php plugin for eclipse (I typically work with java and am very familiar with eclipse). First of all, is it proper practice to develop my site locally directly within the appache /var/www directory? If this is ok, c...

Data for the Columns in Flex

<local:CheckBoxDataGrid id="dg" allowMultipleSelection="true" x="118" y="151" width="557"> <local:columns> <mx:DataGridColumn dataField="firstName" headerText="Select" width="50" sortable="false" itemRenderer="CheckBoxRenderer" > </mx:DataGridColumn> <mx:DataGridColumn id="userID" headerText="User ID" /...

Face detection + Image morphing

Hello, I am looking to create a site like photofunia.com where basically you can apply a large number of effects to an image. I am wondering if someone can guide me in the right direction as to the technology which must be used to achieve the same? Also, are there any open-source commandline utilities available to create such images? I...

embedded web server to run php

Hello all im looking for embedded web server that can parse php do you have experience with such ? ...

Using ".html" to link to a .html.php file - what's the magic?

This is more a question of curiosity. So I was reading a chapter from (Sitepoint's latest PHP/MySQL book), in which the author mentioned using the extension ".html.php" to indicate files that has both HTML and PHP. I tried it out, and discovered this: If I have a file "fileA.html.php", and somewhere in "fileB.html" I have a link thusly...

Caching PHP script outputs on the client side

I have a php script that outputs a random image each time it's called. So when I open the script in a web browser, it shows one image and if I refresh, another image shows up. I'm trying to capture the correct image from visiting the web site through a command line (via mechanize). I used urllib2.urlopen(...) to grab the image, but each...

problem in playlist when we select the different songs

Actually in my website www.musicking.in when the user selects songs one player window will open and that will access the corresponding selected songs xml playlist and the player will play those songs. actually its working fine. but sometimes the problem is when so many users are accesiing the player not playing the songs selected, eithe...

What does "===" mean?

I recently studied some code that I'm supposed to use for different reasons, it's unrelevant. The thing I've noticed is someone using the operator "===" which I can't make sense out of. I've tried it with a function and it corresponds in crazy ways. The language is PHP by the way. Does anyone know what the definition of this operator i...