php

How to build PHP application with multiple language support (English, French, Chinese etc..)

I'm building a web application that uses LAMP and the Smarty template framework. The website will have plenty of static content (about us page, error alerts, confirmation emails etc...). The web application must support multiple languages. Is the following approach appropriate? 1) All static copy on Smarty template pages (html page...

getting external variables via file - eval/include

This should be fairly simple from what I can find online, but I can't seem to get it to work. I've got a widget which I want to enable others to edit (text, images, css, etc). so I've provided them the ability to pass an external page in via a url variable. The problem is that I can't then access the values they provide via the page...

Zend Framework MVC Design

I've asked this question on the zfforums as well, but I maybe I'll get a response here. So the Zend Framework is a general purpose, flexible, loosly coupled, high quality framework. However, I find some of the MVC parts inconsistent and overly complex. Hopefully some of you can justify some of the zf design decisions and answer some que...

What headers do I want to send together with a 304 response?

When I send a 304 response. How will the browser interpret other headers which I send together with the 304? E.g. header("HTTP/1.1 304 Not Modified"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"); Will this make sure the browser will not send another conditional GET request (nor any request) until $offset...

How do you post to the wall on a facebook page (not profile)

Hi, I have a blog site written in php and it posts new blog posts to twitter and a blog ping automatically under the hood using simple http post requests passed using php curl. I have a facebook page for the blog site and want the updates to be posted to the wall on the page, is there a simple way to do this? What I really want is a ...

Are singleline if statements or if statements without { } bad practice?

if ($_GET["asdf"]==1) { /* do something */ } else { /* do something */ } //////////////////////////// if ($_GET["asdf"]==1) /* do something */ else /* do something */ I was told that the first instance was bad by a person I know. I have absolutely no idea whether this is really such bad practice - does it not shorten the amou...

Others frameworks like PEAR

Do you know others frameworks like PEAR (http://pear.php.net) ? I want to use reusable PHP components without using the famous PEAR. I already use a framework (Zend Framework) and i want to use php components who doesn't exists in ZF like payment, encryption, math... ...

Finding a $cid based on $nid in drupal

I have a node in drupal. I want to be able to input a node id and then then have it output a single comment id which was made on that node. How would I go about doing this? Thank you. ...

Understanding Frameworks

What is the best method of understanding how and why a framework was written the way it was? ...

postgresql sequence problems with lastinsertid and zend framework

Hi I have just started working on a project and I am using zend framework and postgresql (normally use MySQL) however I am hitting a problem when I am trying to get the last inserted id when using the Zend_Db insert command. When using the function $db->lastinsertid('users', 'userid'); I get the following error message: SQLSTATE[42P01...

Why does the browser not cache a 301 within an AJAX-request?

This is the XMLHttpRequest: $.ajax({ method: "get", url: "getPage.php", data: $data, dataType: 'json', timeout: 2000, success: function(result) { handleContent(result); } }); This is getPage.php?data=data header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"); header("Cac...

Speed of code execution: ASP.NET-MVC versus PHP

I have a friendly argument going on with a co-worker about this, and my personal opinion is that a ASP.NET-MVC compiled web application would run more efficiently/faster than the same project that would be written in PHP. My friend disagrees. Unfortunately I do not have any solid data that I can use to back up my argument. (neither doe...

How to generate table of contents using dompdf?

Hi I am using the dompdf library of php to generate PDF report from an HTML template. In that html template there is a section table of contents. When genrating PDF i need to update the page number of table of contents. Does anyone know how I can achieve this in dompdf library of php? Thanks in advance. ...

PHP5: Why is try/catch failing?

On my XAMPP/Win XP build, PHP5.2.3 fails to catch any exceptions. None of the examples work, and this: try { throw new Exception('Fail'); } catch (Exception $e) { echo 'Succeed'; } ...results in: Fatal error: Uncaught exception 'Exception' with message 'Fail' in M:\path\to\test.php:4 Stack trace: #0 {main} thrown in ...

Can you put script tags in between php tags?

I'm trying to make a div fade out with jquery after the form validates the user input after pushing submit. I'm trying to avoid the form from fading out before it validates in case the user didn't enter the correct information. I would like to know if I can just add script tags in between my php tags, so that once the validation finishe...

How to run a php script in cron

I have found many questions and articles about this but i still have some difficulties. I'm using the following command /usr/bin/php home/domain.com/public_html/cron/script.php I receive the following error Status: 404 Not Found X-Powered-By: PHP/5.2.8 Content-type: text/html No input file specified. i'm using Cpanel, the file is host...

Best way to call .NET classes from PHP?

What are the best options for connecting PHP apps to logic located in .NET libraries? PHP, since v5.0, supports a DOTNET class that is supposed to let me invoke .NET logic from a PHP script. But it seems there are many problems - I've not been able to get it to work reliably, with arbitrary .NET classes. The doc is sort of slim and wha...

Do you find the view implementations in PHP frameworks convenient?

All the popular PHP frameworks today use their own view layer implementation that is based on pure PHP templates and lots of helpers. I've tried some of them and always found that this approach introduced huge complications to quite simple things. For example, in Zend Framework forms and the pagination use their own solutions to customiz...

Outputting image with underlined text using php GD library

What is the best way to display underlined text and output the result as image with GD or any other library? ...

extra mystery space in php code

I am trying to pass a variable frm php to a javascript function, however a space keeps getting appeneded, and I can not see how. The relevant php code snippet: <p><a href='#' onclick=\"makewindows(" . $html . "); return false;\">Click for full description </a></p>".$brand." <p><a href=\"#\" onclick=\"deleteRec('".$ARTICLE_NO."', '...