php

PHP: performance of static methods vs functions

In PHP, (unlike what i originally thought) there an overhead of calling static methods vs simple functions. On a very simple bench, this overhead is over 30% of the calling time (the method just returns the parameter): // bench static method $starttime = microtime(true); for ($i = 0; $i< 10*1000*1000; $i++) SomeClass::doTest($i); ech...

how to access memcache item created in php from java.

item is json serialized not binary so it is readable. I am getting problem while trying to get the item, with php the key is working fine but when i access the item using same key in java it fails I have only one server so server hashing should not be aproblem I have done a wireshark analysis and seems to be of no help except that: java...

ActiveRecord and many to many relationship ?

I'm trying to implement the Active Record pattern to a ZF project. I used to work with a similar approch before and it works well. But my problem now, is about how to handle many-to-many relationship with my models. Here is an example : Let's say i've an User model. <?php require_once 'MLO/Model/Model.php'; class Model_User extends...

Javascript Alert in META tag

Is there any way to work an alert to run when I echo a META tag which is refreshing the page? The goal is to have the page refresh and then the Alert loads. Example of current line: echo '<META HTTP-EQUIV="Refresh" Content="0"; URL="contact-test.php">'; ...

What is the best MVC, Doctrine2, Datamapper practice?

I am looking into using Doctrine2 with my Zend Framework setup. I really like the datamapper pattern, mainly because it seperates my domain models with my database. My question is what is the best practice for using Doctrine and DQL with my controllers? controllers uses Doctrine DQL/EntityManager directly for saving/loading my domain ...

PHP Format variable

I have a variable as shown below with upper case initials and a space. What would be ideal way to format so that it lower case the initials and puts "-" dash in between. So end result should be "los-angeles": $city = "Los Angeles"; convert to $city ="los-angeles"; ...

Some characters in CSV file are not read during PHP fgetcsv()

I am reading a CSV file with php. Many of the rows have a "check mark" which is really the square root symbol: √ and the php code is just skipping over this character every time it is encountered. Here is my code (printing to the browser window in "CSV style" format so I can check that the lines break at the right place: $file = fopen(...

What PHP function will print the name of an array with its contents?

When I use Smart::Comments in Perl, I can see the name of the hash I am dumping (i.e. %person, below). . . [pdurbin@macbook ~]$ cat /tmp/person.pl #!/usr/bin/perl use strict; use warnings; use Smart::Comments; my %person = ( 'hair' => 'golden', 'eyes' => 'blue', ); ### %person [pdurbin@macbook ~]$ perl /tmp/person.pl ### %perso...

find time to execute MySQL query via PHP

I've seen this question around the internet (here and here, for example), but I've never seen a good answer. Is it possible to find the length of time a given MySQL query (executed via mysql_query) took via PHP? Some places recommend using php's microtime function, but this seems like it may be inaccurate. The mysql_query may be bogged ...

Enumerate all users in LDAP with PHP

I'd like to create a php script that runs as a daily cron. What I'd like to do is enumerate through all users within an Active Directory, extract certain fields from each entry, and use this information to update fields within a MySQL database. Basically what I want to to do is sync up certain user information between Active Directory a...

Drupal: Hierarchical taxonomical breadcrumb trail

Hey all, I'm looking to generate a hierarchical breadcrumb from a taxonomy term (e.g. grandparent/parent/child) when all I have is the TID of "child". I've been toying around with taxonomy_get_tree(), but it seems quite difficult to do without very heavy iteration. There has to be an easier way. Thoughts? Thanks! ...

Help with mysqli_stmt_store_result()

I'm having trouble trying to use $stmt->store_result() after executing a prepared statement. The manual says "Transfers a result set from a prepared statement", but to where? I would ideally like to use it, all nice an buffered in memory, like mysqli->query() returns. The php documentation examples make it seem like the only good reaso...

Encrypt in VBScript/ASP Classic, Decrypt in PHP?

I'm looking to encrypt a string in VBScript, and decrypt it in PHP. I have full control over the VBScript/ASP Classic environment, but zero control over my PHP environment. Given this, what sort of encryption could I use that would be adequate enough to secure a string? Apologies for the vagueness of the question, but I do not know wh...

PHP gettext on Windows

There's some tutorials out there for gettext (w/ Poedit)... unfortunately, it's mostly for a UNIX environment. And even more unfortunate is that I am running my WAMP server on Windows XP (but I am developing for a UNIX environment) and none of the tutorials can get gettext working properly for me. From the man page (http://us3.php.net/...

Timeout to logout with reset loop

I'm trying to implement an automatic timeout inside of an existing PHP application. My goal is to have the system notify the user 15 seconds before the automatic timeout is set to occur and give them the opportunity to 'reset' the timeout timer. I'm using jQueryUI bits as a part of all of this. This chart may help describe what I'm tr...

Making a distribultable standalone program in PHP

Hello, I've decided to code some applications in PHP that are supposed to run offline in the user's machine. However, I can't seem to find an user-friendly install wizard to create a local server in where the script will run. Any ideas? PS: Here's an example of what I want: http://www.nolapro.com ...

PHP: Checks to see if a string is utf8 encoded? How?

function seems_utf8($str) { $length = strlen($str); for ($i=0; $i < $length; $i++) { $c = ord($str[$i]); if ($c < 0x80) $n = 0; # 0bbbbbbb elseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb elseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb elseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb elseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb ...

Mail php - errors with form.

Hi, I'm wondering ... In the head of the doc is the mail body and it is the details in the body of the document. They don't match because I made some html changes but I can't just past it into it I have to almost go through it manually, does this make sence? Lol Like it does this for the php code '.round($mon_pay_shield_wmant).'' and...

Getting Modified Preorder Tree Traversal Data into an Array

What is an efficient way to put the tree data into an array? I followed the sitepoint tutorial to retrieve the tree data. However, the tutorial only shows how to output the tree, not how to make a multidementional array. I used SELECT title, lft, rgt FROM tree_structure WHERE lft BETWEEN $parentLft AND $parentRgt ORDER BY lft ASC ...

E-mail sent via CakePHP shows up with blank message body when accessed via POP

I'm writing a small CakePHP application for an organization and have included a simple contact form that accepts an email address, subject, and message, and emails the message to the address. Everything seems to work fine, and any email sent to myself or anyone at the organization arrives just fine, except if they access the message via...