php

Insert array into database in a single row

I wonder if this would be doable ? To insert an array into one field in the database. For instance I have a title, I want to have that title with only one id, but it's going to be bilingually used on the website. It feels a bit unnecessary to make another table to have their global ids and then another table with the actual titles link...

How to get proper line number when using trigger_error in PHP?

I am using trigger_error to "throw" errors in a custom class. My problem is that trigger_error prints out the line number where trigger_error was called. For example, given the following code: 01 <?php 02 class Test { 03 function doAction() { 04 $this->doSubAction(); 05 } 06 07 ...

How do I create a copy of an object in PHP?

It appears that in PHP objects are passed by reference. Even assignment operators do not appear to be creating a copy of the Object. Here's a simple, contrived proof: <?php class A { public $b; } function set_b($obj) { $obj->b = "after"; } $a = new A(); $a->b = "before"; $c = $a; //i would especially expect this to create a cop...

Setting up your first SSL page using PHP5

I would like to use a secure SSL login on my website! I have not used SSL before, so I am looking for some good reading. Can anyone tell me where I can find some sample code of SSL snippets or page code. (Not too technical) I do have a static IP My host is set-up to handle SSL Pages. Interested in: Basic page code. / Tree structure...

MVC data design problem with Zend framework.

If I have a class representing access to one table in my database in a class:table relationship, so I can hide table details in one class. But as any useful application I have to query several tables. How can I accomodate this using the class:table design? ...

Easy IIS install of php

Are there any "all-in-one" installers for php + mysql on iis? Preferably with a gui configuration interface. ...

Why is require_once so bad to use?

Everything I read about better php coding practices keeps saying don't use require_once because of speed. Why is this? What is the proper/better way to do the same thing as require_once (if it matters, i'm using php5) ...

Calculating days of week given a week number

Given a week number, e.g. date -u +%W, how do you calculate the days in that week starting from Monday? Example rfc-3339 output for week 40: 2008-10-06 2008-10-07 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12 ...

PHP's file_get_contents not returning until remote servers' keep-alive limit is exceeded

From one apache server file_get_contents returns the contents of a url straight away. On another apache server file_get contents won't return the contents of the same url until the keep-alive limit of the server hosting that url has been expired. The 2 php servers are retrieving the same url but through different network routes. What ...

Better way to profile?

Is there a better way to profile code then: $start1 = microtime(TRUE); for($i=0;$i<count($array);$i++) { //do something } $time1 = microtime(TRUE) - $start1; ...

Zend Framework fetchAll

Can i override fetchall method in a model? I need to check sth everytime fetchAll is called. The model extends Zend_db_table_abstract ...

Where to store uploaded files (sound, pictures and video)

A while a go I had to developed a music site that allowed audio files to be uploaded to a site and then converted in to various formats using ffmpeg, people would then download the uploaded audio files after purchasing them and a tmp file would be created and placed at the download location and was only valid for each download instance a...

How do I detect Mobile Safari server side using PHP?

Mobile Safari is a very capable browser, and it can handle my website as it is perfectly. However, there are a few elements on my page that could be optimized for browsing using this device; such as serving specific thumbnails that are smaller than the desktop counterparts to help fit more content into the screen. I would like to know h...

The most flexible framework architecture for web development?

Obviously, there is no one single solution that would satisfy everyone's needs; an architecture is always a trade-off. I want to create a framework, originally aimed at RAD of web games. Target language is PHP, although the architecture should be widely applicable. Goals that I have in head for this framework are: flexibility in ways yo...

Implementing LDAP compliance

I'm working profesionally on a php web application which contains contacts, among other data. I was wondering how hard it would be to make this data available to external programs using the LDAP protocol. Are there specific tools out there for this? I couldn't really find anything, but I can't imagine I'm the first to think about this. ...

Replacing or Removing a new line with something else but only between single or double quotes using PHP on a CSV file

I have a CSV file that holds about 200,000 - 300,000 records. Most of the records can be separated and inserted into a MySQL database with a simple $line = explode("\n", $fileData); and then the values separated with $lineValues = explode(',', $line); and then inserted into the database using the proper data type i.e int, float, s...

In PHP, how do I find the value associated with a specific key.

I have two arrays. One contains id=>count and the other contains id=>name. I'm trying to produce a single array that is name=>count. Any suggestions on a straightforward way to do this? I have looked at the Array Functions in the PHP Manual and didn't see anything that stood out as doing what I want, so I'm guessing I'll need a combinat...

Seriously, should I write bad PHP code?

I'm doing some PHP work recently, and in all the code I've seen, people tend to use few methods. (They also tend to use few variables, but that's another issue.) I was wondering why this is, and I found this note "A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. ...

Command Line Password Prompt in PHP

I'm writing a command line tool to help my web app. It needs a password to connect to the service. I'd like the script to show a password prompt so I don't have to pass it as a command line argument. That's easy enough, but I'd like it to not echo the password to the screen as it's typed. How can I do this with PHP? Bonus points for ...

How do I start reading the PHP source code?

The source code for the PHP interpreter is absolutely mystifying to me. The thing is, I'd like to learn more about it, so I can avoid making Schlemiel-style mistakes. This is a huge project, some nearly sixty megs in size. How do I go about reading it? Is there an article or a book out there somewhere to help me begin to make some se...