php5

How to test controllers with CodeIgniter?

I have a PHP web application built with CodeIgniter MVC framework. I wish to test various controller classes. I'm using Toast for unit testing. My controllers have no state, everything they process is either saved into session or passed to view to display. Creating a mock session object and testing whether that works properly is straight...

Encoding JSON for jQuery Calendar

Hi, I'm trying to use the PHP json_encode function to encode some JSON to send along to a jQuery plugin that will render out a calendar. The plugin's name is FullCalendar. I've started on grabbing event data from a MySQL database and encoding it in a JSON string, but I've run into a problem. The default JSON example that comes with the...

PHP Class won't return to a String

Hi, I'm fairly new to PHP so I have a small problem as I'm learning: I built a Class called DataStrip.php <?php final class DataStrip { public function DataStrip() { // constructor } public function stripVars($vars) { return $vars; } } ?> and then I'm trying to pass the public function stripVars a value: <?php inc...

Looking for a simple mySQLi class example with descriptions

Hi, I am looking for an example of a simple, but functional example of a class extending the mySQLi class in PHP5. I am interested in stored procedures also. Basically what I need is an example of a practical and usable class. I learn best by example and unfortunately I have been unable to find any site or book that seems to have a reall...

Get a URL from a String

For a little while now I've been searching for a code to get URL's out of a string using PHP. I'm basically trying to get a Shortened URL out of a message, and then later do a HEAD request to find the actual link. Anyone have any code that returns URLs from strings? Thanks in advanced. Edit for Ghost Dog: Here is a sample of what I...

Type casting for user defined objects

Hi Just like we do with __ToString, is there a way to define a method for casting? $obj = (MyClass) $another_class_obj; ...

Does $_REQUEST have security problem?

My henchman is learning PHP currently, and he sent me his PHP code, and I found that he uses $_REQUEST in his code. The textbook I read says that $_REQUEST has security problem so we better use $_POST. so I replied to the henchman that we better to use $_POST. Is this OK? ...

Fatal error: undefined function - why?

I'm new to object oriented programming in PHP. I included a class and called it, then, inside this class's constructor I'm calling a private function called handleConnections. For some reason, it's giving me a fatal error (undefined function). Any idea why? The class: class Test { function __construct() { handleConnections(...

Registry design pattern...good or bad?

The following code is from a tutorial (http://net.tutsplus.com/php/creating-a-php5-framework-part-1/), not mine. I have a few questions about this code... The article claims it is using the "registry design pattern"; is that the universal name for this design in the industry? Is there another similar patter out there that would be a b...

SimpleXML, associative arrays, and XPath

Hey everybody, I have a question about xpath and arrays. What I was wondering was if it is possible to use xpath on some simpleXML and have it return an associative array of node names and their values. For example, say I have the following XML: <element1 page="1">blah</element1> <element2 page="1">blah blah</element2> <element3 page=...

build PHP with ant scripts

Hey everyone, I was just wondering how I use Ant to build my web applications that I have written in PHP? I've googled around a bit and I have seen that it is possible but there are not any examples of the basic idea or any advanced use for them. Can any of you help me out? Thanks! ...

What is PDO scrollable cursor?

What is "Fetching rows with a scrollable cursor" all about? ...

Process a block of HTML, ignoring content within specific tags

On a blog I wish to pass all of the text for a blog entry through a PHP script to process quotes and some other items into nice typographic characters. The blog text in question contains HTML, and in particular will highlight code snippets contained within <pre><code> ... </code></pre> blocks. The code blocks can appear randomly and in ...

calculating a top 5 in php and mysql

Hey I've made a rating system in php and mysql and now I want to select a top 5, I've made something but if a user adds a rating (with the max) it's nr 1 ranking. How do you guys do it in php and mysql ? the table looks like this: -- id -- mid -- uid -- rating The rating is a number from 1 to 5 Thanks in advance! ...

Is PHP for Windows the same as Linux, Mac, etc.?

If I write PHP (php5 if it matters) on Windows and Apache is the same as writing PHP on another OS and Apache? I do not mean things like file paths. Thank you. ...

PHP Xml Attribute Parsing

I am Parasing XML currently using: $data = simplexml_load_string($xmlFile); foreach($data->item as $key => $current){ echo($current); } However I'm wondering, if a hit an element that looks like this: <thumbnail url="http://foo.bar" height="225" width="300"/> How do i pull the inner parts of this? (height, url, width) Thanks! ...

trying to understand something about php gd

if i have something like this <?php $image = imagecreate(300,20); $background = imagecolorallocate($image,0,0,0); $foreground = imagecolorallocate($image,255,255,255); imagestring($image,5,5,1,'sarmenhb, $foreground); header('Content-type: image/jpeg'); imagejpeg($image); ?> how does php know the first imagecolorallocate function wi...

print from php in macosx

Does anyone know a way to print from php5 in macosx leopard similar to the windows approach using php_printer.dll? I'm using macosx 10.5.7 and php 5.2.8. ...

Whats the correct way to embed images PHPMailer with an HTML email?

I want to send an Newsletter with PHPMAiler. The newsletter does work, but I'm wondering if there is a better option to do this. What I have is. HTML Page Images Now my code looks as follows $mail = new PHPMailer(); //Adding the body $body = file_get_contents('template/index.htm'); $mail->Subject = "PHPMailer Test Subject via ma...

image crop with gd then upload to db but not resizing.

my code basically should crop the image to 219px by 127px and save the image to the database but im getting errors and cant figure it out. <?php if(isset($_POST['btnupload']) && $_FILES['imglogo']['size'] > 0) { $tmpname = $_FILES['imglogo']['tmp_name']; $imgsize = $security->secure($_FILES['imglogo']['size']); $imgtype = $security->s...