php5

Is this online tutorial a good starting point for creating a PHP5 framework for learning reasons?

I have found this tutorial online http://net.tutsplus.com/tutorials/php/creating-a-php5-framework-part-1/ I have created myself a simple sort of framework, but I have not been too knowledgeable whether I have followed best practices and the like... which I really would like to do. I am looking at making my framework more unified by th...

Has trigger_error() in PHP been deprecated for something better in PHP5?

I used to use this when I wanted to trigger errors in PHP, coming from a PHP4 background. Note I had my own set_error_handler() for handling these errors. if ($error) { trigger_error('Sorry, error has occured'); } I can't remember where, but sometime ago someone told me I should be 'using exceptions'. As I'm re factoring a lot of ...

Passing arguments to the Class Constructor

How can I pass a arbitrary number of arguments to the class constructor using the Object() function defined below? <?php /* ./index.php */ function Object($object) { static $instance = array(); if (is_file('./' . $object . '.php') === true) { $class = basename($object); if (array_key_exists($class, $instance) =...

How to make several tests using MDB2 with PHPUnit DataBase?

I use PHPUnit DataBase to test some class using MDB2. All is well, since I encounter the second test, which returns an error: Caught exception: Object of class MDB2_Error could not be converted to string When I place the second test in place of the first one, the new first test is OK, but the second one returns the same error!...

PHP: call method in the context of each object of the inheritance chain

Look at the following code snippet: <?php class A { function fn() { print 'Context: Class:' . get_class($this) . ' Parent:' . get_parent_class($this) . "\n"; if(get_parent_class($this)) { parent::fn(); } } } class B extends...

Where can I get a security code review for free?

Dear Abby, I've been working on a PHP website which utilizes a MySQL database (using PDO). I would just like to know it is secure before I go ahead and release it to the public. It is a free, non-profit website so I don't really plan on making money from it and therefore I would rather not invest hundreds or thousands of dollars for a s...

Class mapping in ZendAMF - actually useless?

Some concerns about ZendAMF.... one question about ZendAMF and the integration of Flex (AS3) with PHP5. What is the sense of definining Value Objects in PHP and perform all the explicit class mapping with AS3 classes, when type checking is not enforced anyways? Example: I create a Contact object in PHP, add some non-member variables an...

Load dropdown according to the value of another dropdown - without refreshing the page in PHP

Hi Friends, I have created a page in PHP, in that i need to load a dropdown2 corresponding to the value of dropdown1 without refreshing the page. The values for those dropdown's are from the database. I dont want to refresh the page for every click, Please guide me regarding this.. ...

Mail returns false

I'm currently using a custom made library at my job. Until just rencently the library was working perfectly. It apparently return false since about today. The library itself it basically a wrapper around the function mail. It builds the "boundaries" parts and everything. Since the class is quite big enough I wont post it here ... but I...

What are best practices to reduce junk mail using PHP and captcha?

My site has the following code to send email. if($_SESSION["captcha"]==$_POST["captcha"]) { $msg="Require Services :\t$_POST[service]\n"; $msg="Name :\t$_POST[name]\n"; $msg.="Company Name :\t$_POST[co_name]\n"; $msg.="Address :\t$_POST[address]\n"; $msg.="Mobile :\t$_POST[mobile]\n"; $msg.="Phone :\t$_POST[phone]\n"; $msg.="E-mail :\...

PHP text parsing and / or make your own language?

Been Googling around without finding much at all, so does anyone know of a class or library that helps you parse any sort of language, like a Domain Specific Language (I'm creating one, so I'm flexible in what the syntax and format can be) into either PHP code or some helpful struct or a class hiearchy or ... ? Anything goes at this poin...

Best PHP 5 Templating Techniques?

I am looking to build my own templating layer in php as part of my OOP Framework, but Im looking so some example of how to do this properly. I'd like to avoid parsing each html file to find comments that tell the templating engine what to do but rather use a faster/cleaner/modern technique. I just need some examples, because i've looked ...

Why can't I pass user sessions between subdomains?

First of all, I have used ALL of the suggested methods in this SO article: http://stackoverflow.com/questions/644920/allow-php-sessions-to-carry-over-to-subdomains For your convenience, here are the tips I already followed: Here are 3 options. Place this in your php.ini: session.cookie_domain = ".example.com" In your ...

How might one go about implementing a forward index in PHP?

Hello all, I am looking to implement a simple forward indexer in PHP. Yes I do understand that PHP is hardly the best tool for the task, but I want to do it anyway. The rationale behind it is simple: I want one, and in PHP. Let us make a few basic assumptions: The entire Interweb consists of about five thousand HTML and/or plain-text...

SQL design and / or PHP class for storing dynamic two-dimensional arrays?

I need an elegant way to store dynamic arrays (basically spreadsheets without all the functionality) of various sizes (both x and y), mostly being used as ENUMs, lists, lookup data, price sheets, that sort of thing. Multi-lingual would be a great bonus. Speed of the essence. Here's an example of a typical "sheet" ; | 1 | ...

Finding locale date representation in PHP5

Hi, my site changes its locale dependent upon either user settings or browser settings (where the user hasn't set their preference). I am using amline charts, the stock chart specifically, which requires the date format in 'MM/DD/YYYY' or 'DD-MM-YYYY', I guess so the chart knows how to understand the dates. There are many ways to format ...

Newlines in Javascript and PHP5

Hi, I have a CSV string that is embedded within an XML document, which is necessary for a flash chart which uses XML. The problem is that the chart gets the settings from the HTML file through a javascript snippet, like so: <script type="text/javascript"> // <![CDATA[ var so = new SWFObject("/gr/amstock.swf", "line", "100%",...

Locale date format in PHP5

Hi, my site changes its locale dependent upon either user settings or browser settings (where the user hasn't set their preference). I am using amline charts, the stock chart specifically, which requires the date format in 'MM/DD/YYYY' or 'DD-MM-YYYY', I guess so the chart knows how to understand the dates. There are many ways to format ...

PHP constructor executes before arguments for nested variables can be supplied.

First things first, here is a little snippet code to help explain my problem: <?php class foo { public $title; __construct{ echo "<html>\n"; echo "<head>\n"; echo "<title>".$this->title."</title>\n"; echo "</head>\n"; echo "<body>\n"; } /** * * I get $title from index....

call for action in zendframework

i am new to zendframework i try to run the sample quickstart if i give the url without /pubilc it dosn't work but if i add the /public i get the frist html page when i send the from to get the next page i get error The requested URL /QuickStart/public/extract was not found on this server. please how do i start whihout the public in the ...