php

What web-oriented language should I learn after PHP?

I'm an experienced PHP developer, but I wouldn't call myself a great programmer. I would really like some suggestions of a language to learn to increase my understanding of good programming while still remaining within the web. What should be my next step if I were to continue my career in website application development? ...

Php and zend framework

how can i easily implement queries in zend framework ? ...

When to use xml with xsl instead of HTML?

I like .NET webcontrols and you manipulate things, that's common consensus, but XML and XSL is so great, because you have UI logic that is platform & language-independent, so one day I change the app to php, java or whatever and i can reuse all the presentation logic. Moreover, XSL has the possibility to call .NET (or whatever) methods ...

PHP date calculation

What is the best (date format independent way) in PHP to calculate difference in days between two dates in specified format. I tried the following function: function get_date_offset($start_date, $end_date) { $start_time = strtotime($start_date); $end_time = strtotime($end_date); return round(($end_time-$start_time)/(3600*24)); } ...

PHP library for openID

Which is the best PHP library for openID integration? ...

PHP:Writing to excel file using PEAR

I have installed PEAR, Spreadsheet_Excel_Writer and OLE. The sample program is executed successfully but when I try to read the file it shows garbage values. I also tried $workbook->setVersion(8); and $worksheet->setInputEncoding('UTF-8'); I am using this tutorial and Google lot for this problem. http://www.sitepoint.com/article/gettin...

Kerberos Authentification in PHP

Let's just assume that I don't know much about Kerberos - just the basics. I have... Debian Linux 2.6 Webserver Apache 2.2 mod_auth_kerb/5.3 PHP/5.2 a (working) Kerberos Realm Windows Client Firefox 3 an logged in identity "[email protected]" in MIT Network Identity Manager How do I use this information in a PHP script so that...

PHP: How to set a timeout on socket_read?

I was wondering how can I set a timeout on a socket_read call? The first time it calls socket_read, it waits till data is sent, and if no data is sent within 5 secs I want to shutdown the connection. Any Help? I already tried "SO_RCVTIMEO" with no luck. Im creating a socket with socket_create() and listening on it for connections, then ...

How do I test for an Oracle connection

I'm trying to connect to an Oracle DB which is currently offline. When it's online it's not a problem, however, now that it's offline my program is getting hung up on the $connection = oci_connect() line and timing out. How do I simply check the connectio and bail out if it's not there? ...

Template ifs using regex

Hey everyone, I'm working on a PHP application that needs to parse a .tpl file with HTML in it and I'm making it so that the HTML can have variables and basic if statements in it. An if statement look something like this: ` <!--if({VERSION} == 2)--> Hello World <!--endif --> To parse that, I've tried using preg_replace with no luck. T...

Autocomplete for PHP Objects with classes in PDT/Netbeans?

When I define an object of a class using new like this $blah = new Whatever(); I get autocomplete for $blah. But how do I do it when I have $blah as a function parameter? Without autocomplete I am incomplete. Edit: How do I do it if it's in an include and PDT or Netbeans can't figure it out? Is there any way to declare types for vari...

How to programmatically determine the document root in PHP?

Here's a problem that I've been running into lately - a misconfigured apache on a webhost. This means that all scripts that rely on $_SERVER['DOCUMENT_ROOT'] break. The easiest workaround that I've found is just set the variable in some global include files that is shared, but it's a pain not to forget it. My question is, how do I determ...

Locking class members in PHP

In PHP, if you define a class, and then instantiate an object of that class, it's possible to later arbitrarily add new members to that class. For example: class foo { public $bar = 5; } $A = new foo; $A->temp = 10; However, I'd like the ability to make it impossible to add new members this way. Basically I want the class to ON...

mysqli prepared statements and REPLACE INTO

I have to following code: http://www.nomorepasting.com/getpaste.php?pasteid=22987 If PHPSESSID is not already in the table the REPLACE INTO query works just fine, however if PHPSESSID exists the call to execute succeeds but sqlstate is set to 'HY000' which isn't very helpful and $_mysqli_session_write->errno and $_mysqli_session_write-...

Declaring Variable Types in PHP?

I was trying to get my Netbeans to autocomplete with PHP, and I learned that this code is valid in PHP: function blah(Bur $bur) {} A couple of questions: Does this actually impose any limits on what type of variable I can pass to the blah method? If this is just to help the IDE, that's fine with me. How can I declare the type of a v...

Convert HTML + CSS to PDF with PHP?

Ok, I'm now banging my head against a brick wall with this one. I have an HTML (not XHTML) document that renders fine in Firefox 3 and IE 7. It uses fairly basic CSS to style it and renders fine in HTML. I'm now after a way of converting it to PDF. I have tried: DOMPDF: it had huge problems with tables. I factored out my large nes...

What is the best code location to define table relationship methods using Zend Framework models?

I'm creating a simple tag system that allows me to link a tag to almost everything in my application. In order to facilitate this, I created a table called "objects", referenced by my model "Object". I've got three models setup at the moment: Tag (with TagObject defined as a dependentTable) Object (with TagObject defined as a depended...

PHP MSSQL character inconsistencies

A very strange thing happens to me when I try to insert Non-Latin characters (e.g. Hebrew, Arabic etc. using N'string to insert') using PHP. This thing happens with all the extensions I've tried: mssql, odbc and native driver. When inserting through PHP code, only when selecting through PHP it works fine and I can read what I've inserte...

php: Calling Static Classes through a variable

Is there a way to call Static Classes / Methods by name? Example: $name = 'StaticClass'; ($name)::foo(); I have classes which I keep all static methods in and I'd like to call them this way. ...

How do I remove Word markup crap when inserting to a form?

I'm building a CMS in PHP and one dread I have is that the users will have to fill the data in from existing Word (and Excel, but nevermind that) documents. Now, I've seen what happens when they carelessly copy and paste from Word to a textarea: the database got filled with crap markup. Now, I could certainly strip all markup myself, bu...