php5

Abstract class 'n Interface, specifically in PHP

This question is in continuation to my previous post located here. Since there is no way to post code sample again without editing your original post, I am starting a new post. And also, this contains PHP code. I am writing two classes, first is for opening and closing connection to the database, and the second is to provide various r...

Execute PHP code after something is displayed in the browser

I want code in a php5 page be executed after all of the page (or maybe even after the first part of the page) is displayed. I would prefer no javascript and no frames / iframes and no redirects. Just one page written in php, only emitting html. I remember some special function in php5 to register a callback function that will be execu...

Class call a function in another class....

I have a class like: <?PHP abstract class dbCon { public function OpenConnection() { // Do Something; // On error: $this->ShowError(); } abstract function ShowError(); } class ErrorHandling extends dbCon { public function ShowError() { // Show error } } ?> There is a ...

Avoiding many try...catch blocks

I have various functions in a class. In each function I use try...catch. Is there any way to simplify this? I want to make one error class and it must be accessible from any file in my project. I don't want to use try..catch in each function, rather it should be automatically directed to the Error class. ...

Problem with Custom Error Handler.

Please refer my previous post here. I did changes accordingly but getting error. Please help me figure out the errors in this code. My IDE (Aptana) is giving red underlines on many lines of this code: <?php /* Include dependency */ require_once("./Config/dbconfig.php"); abstract class dbconnection { var $conn; try { ...

CodeIgniter - Using existing classes with CodeIgniter, any problems with including them directly?

I am considering using CodeIgniter as the framework for my next web-application. However, I already have a large number of helper classes and data structures defined. I could add them to the application's library but I have to rename a large number of files and classes' name to match the criterion Can I just directly include files as in...

How do you store an integer while in a foreach loop

This may be simple to some of you guys but im a novice coder. How do i make this foreach loop terminate after i loops. The number keeps resetting as it loops through another condition. There are multiple a's. About 100 so it i never gets up to 250. $i = 0; foreach ($a as $b) { //do function i++; if (i == 250) { exit;...

CodeIgniter PHP5 Exceptions

I've been wondering what's the best way to deal with exceptions on CodeIgniter. The usual way is to use triger_error() or log_message() ... however I've been wondering if there's a better way using try/catch. Any tips or recommendations on how to implement this into CodeIgniter? Currently I'm extending the Exceptions class, but I would...

ECommerce, product and stock how to page those

Hi, I am building a EC system for a client, this client is selling second hand products. My DB scheme is roughly like this +-------------+ +-------------+ +-------------+ | Category | | Product | | Stock | +-------------+ +-------------+ +-------------+ | category_id | | category_id | | stock_id | | path | | prod...

File Upload in Zend

Hello every body, i m using zend form & create its elements using the code below. // To create text box. $txt = $this->CreateElement('text', 'txtName'); $txt = $this->setLabel('First Name'); $elements[] = $element; it works fine & it is posted firm form as well. But when i used the same technique to show a browse button, like. // To ...

How to tell what class you extends?

Is there a function that tells what class you are extending? Like function_exists? I want to use this in an __autoload function that if it detects a class that extends mysqli, then I will automatically connect it to the database. If there is a better way to do this then I will appreciate it. Thanks! ...

How do I create an XML file with php and have it prompt to download?

I'm using domdocument to create an xml file: $dom = new DOMDocument('1.0', 'iso-8859-1'); echo $dom->saveXML(); When I click the link to this file, it simply displays it as an xml file. How do I prompt to download instead? Furthermore, how can I prompt to download it as 'backup_11_7_09.xml' (insert todays date and put it as xml) inste...

Regular expressions help

Hi guys! Help with regular expressions needed. I'm trying using regular expressions and preg_match_all find blocks <character>...</character>. Here is how my data looks like: <character> 杜塞尔多夫 杜塞爾多夫 <div class="hp">dùsàiěrduōfū<div class="hp">dkfjdkfj</div></div> <div class="tr"><span class="green"><i>г.</i></span> Duesseldorf ...

How do I remove parts of a sentence?

Hello! You are with Andy. Good job! Hello! You are with Naruto-san. Good job! Hello! You are with DragonFang. Good job! Hello! You are with Adam Chan. Good job! Hello! You are with Dude. Good job! Hello! You are with Signore. Good job! Hello! You are with Athena. Good job! Hello! You are with EL NwithJA. Good job! Hello! You are...

Creating a file upload template in Doctrine ORM

Hey all. I'm using Doctrine 1.2 as my ORM for a Zend Framework Project. I have defined the following Model for a File. File: columns: id: primary: true type: integer(4) unsigned: true code: type: string(255) unique: true notblank: true p...

Can't Delete cookie in user class with php

Hi everyone, i think my problem is a little weird, ive wrote a little class to log in/out user, entire system is based in MVC pattern, and my libraries are custom and self written, but the problem: when i log in the user with out the $remember flag, no problems, sessions are easily set and unset. but when i activate the $remember and i ...

Debugging 500 Internal Server Error on PHP running on IIS7 cluster

Recently my ISP switched our website to an IIS7.0 high availibility cluster. The website is running on PHP5.2.1 and I can only upload files (so no registry tweaks). I had tested the website before and everything seemed to be working, but now the checkout page fails with: 500 - Internal server error. There is a problem with the resource...

A button to start php script, how?

I want to make a button that starts my php script after I click it. So do I just make 2 separate files and have action post to the php file and then let it start? or is there a better way to do this? Possibly in one document? Update: Well, I basically made a script that would do a series of a loops until it's finished. So usually when ...

PHP5 - What is the cost of RTTI (get class' name and etc.) in PHP5?

I notice that some PHP frameworks, such as Kohana and CodeIgniter would look at the class name of a class to perform auto-loading. Traditionally, RTTI is expensive for C++; how expensive it is for PHP5, in comparison to: A direct message call Looking up a key in an associative array Doing a message call via variables ( $class = 'foobar...

upload large files using php, apache

Hi All, I want to upload files of around 150 MB using PHP and Apache server. With my code i can upload upto 5MB $path = $_COOKIE['Mypath']; $target_path = "uploads/".$path ; if(!isDir($target_path)) { mkdir($target_path); } # Do uploading here $target_path = "uploads/".$path ."/"; $target_path = $target_path . basen...