php

php fsockopen

I have a simple php script on a server that's using fsockopen to connect to a server. <?php $fp = fsockopen("smtp.gmail.com", 25, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { echo fgets($fp, 1024); fclose($fp); } ?> The problem is the the script times out and fails to connect. If i change the...

Which IDE is for me?

Hey everyone, I'm currently using PSPAD as my main editor, but I'm looking to get something more full featured. I code in PHP, but occasionally modify HTML and CSS code too. I am looking for: Directly editing a file over FTP - must sync / commit changes on save - NOT manual file transfer / update. This is a must for me. Adjust conte...

Remembering checked checkboxes across pages - what's the best way?

I'm needing to add functionality similar to Gmail where the checkboxes on a list of items is remembered across multiple pages of results and when going away and coming back to the result. What I'm trying to figure out is the best way of doing this. I'm using PHP and likely jQuery. My first thought is to add an onClick to each checkbox t...

File exists php code.

<?php function data_info($data) { if ($data) { while (!feof($data)) { $buffer = fgets($data); if (file_exists($buffer)) { $bufferArray[$buffer]['Exists'] = (file_exists($buffer)); $bufferArray[$buffer]['Readable'] = (is_readable($buffer)); $bufferArray[$buffer]['Writable'] = (is_writable($buffer));...

Hotmail / Yahoo (Others?) blocking email notifications?

I've got a website (currently in development for a third party, I'm sorry I can't show) that requires users to confirm their contact information by, clicking on a link sent to their email address, upon registration for the website. It's a pretty standard practice, not very technical or unique, which is why I was surprised to find that Ho...

natural language identification in PHP

I am looking for an automatic language identification tool written in php. The tool should receive as input a string, and output the name of the (natural) language the string is written in. A perl example is TextCat, ported to Java by Knallgrau New Media Solutions. Does anyone know of a PHP port? Or another similar PHP tool? ...

What do you think about this weird idea about how to configure development/staging/production instances?

I just got a weird idea about how to configure environment-dependent parameters. Sort of like parameters you can find in Rails' config/database.yml In my current project I use PHP and Litespeed Web Server (though the same technique applies to PHP + Apache), and I thought... 'why not use mod_rewrite for this?'. I have separate virtual ho...

MySQL-problem when baking with CakePHP.

I am currently reading "Beginning CakePHP:From Novice to Professional" by David Golding. At one point I have to use the CLI-command "cake bake", I get the welcome-screen but when I try to bake e.g. a Controller I get the following error messages: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/my...

multi words PHP arrays replacement

<?php $string = 'The quick brown fox jumped over the lazy dog.'; $patterns[0] = '/quick/'; $patterns[1] = '/brown/'; $patterns[2] = '/fox/'; $replacements[0] = 'slow'; $replacements[1] = 'black'; $replacements[2] = 'bear'; echo preg_replace($patterns, $replacements, $string); ?> Ok guys, Now I have the above code. It just works well. N...

Automatically reformatting inherited PHP spaghetti code

I've taken over a mixed PHP4/PHP5 project which has been handed down from developer to developer, with each one making things worse. Before I spend too much time on it I'd like to develop a base-standard, with consistent formatting at a minimum. Can anyone recommend a utility (Linux or Mac OS X preferably) that will reformat the code? ...

Can PHP do a fairly trivial inheritance thing?

I have the following code: abstract class AbstractParent { function __construct($param) { print_r($param); } public static function test() { return new self(1234); } } class SpecificClass extends AbstractParent {} When I invoke SpecificClass::test(), I am getting an error: Fatal error: Cannot instantiate abstract class Abstract...

late static binding: which languages commonly used for web development support it?

Lately I've been seeing a lot of talk regarding PHP's lack of late static binding until 5.3. From what I've read proper implementations of stuff like ActiveRecord are not possible until the language has this feature. So, I'm curious about: Which languages do support it, specifically those commonly associated with web development suc...

Get all the defined functions for an object

Is there an equivalent of get_defined_functions() which only shows the functions of a given object? Example usage and output: class A { function foo() { } function bar() { } } class B extends A { function foobar() { } } $b = new B(); print_r(get_object_functions($b)); // Array ( // 0 => "foo", // 1 => "bar", // 2 => "fo...

What is the best collation to use for MySQL (with PHP)

I'm wondering if there is a "best" choice for collation in MySQL for a general website where you aren't 100% of what will be entered? I understand that all the encodings should be the same, such as MySQL, Apache, the HTML and anything inside PHP. In the past I have set PHP to output in "UTF-8", but which collation does this match in MyS...

Is the PHP contractor market in the UK being affected by the recession?

Please comment if you are a UK-based freelance PHP developer. Are there just less contracts around because its December or will PHP developers feel the crunch? ...

javascript function not behaving correctly

hello, I have this little function function makewindows(){ child1 = window.open ("about:blank"); child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>"); child1.document.close(); } Which whatever I try, simply outputs the php code as the html source, and not the result of the php code...

PHP filter() function - why?

Why would I want to use PHP's filter library? Why wouldn't I? It seems to try and do a bit of clean-up (it's awful when you have to work with regular expressions), but on the other hand function naming and parameter constants seem to be a disaster, if you ask me. It must have been included in PHP for a reason, but I just don't seem to l...

PHP - using $_GET / $_POST instead of $_REQUEST

Besides the fact that $_REQUEST reads from cookies, are there any reasons why I should use $_GET and $_POST instead of $_REQUEST? What are theoretical and practical reasons to doing so? ...

Character encoding problem - PHP output, read by .NET, via HttpWebRequest

I have a PHP script (running on a Linux server) that ouputs the names of some files on the server. It outputs these file names in a simple text-only format. This output is read from a VB.NET program by using HttpWebRequest, HttpWebResponse, and a StreamReader. The problem is that some of the file names being output contain... unusual c...

Add LDAP entry to Active Directory via ext/ldap

Using ext/ldap I'm trying to add entries to an Active Directory. As long as I only use one single structural objectClass everything works as expected, but as soon as I try to add an entry with a second auxiliary objectClass, the server reports an error: Server is unwilling to perform; 00002040: SvcErr: DSID-030F0AA0, problem 5003 (...