php

PHP Forking Randomly Does Parent Or Child Process Depending On What Finished First what am i doing wrong ?

Hey there, I have a simple script that which is suppose to load 2 separate pages at the same time and grab some text from them, however it loads either the parent process or the child process depending on what finishes first, what am i doing wrong ? I want the 2 processes to work simultaneously, here is the example code: <?php $pid = ...

Can you suppress a single php file that won't parse/compile from showing as an error in Eclipse?

We are currently using Aptana for PHP and Eclipse for Java. While Aptana is built on Ecplise, it treats PHP files differently when they won't parse/compile. I'd love to use Eclipse for both, but I can't figure out how to suppress errors that should be ignored. We use simpletest for all of our projects so we have it included in our "core...

What makes PHP slower than Java or C#?

This is something I've always wondered: Why is PHP slower than Java or C#, if all 3 of these languages get compiled down to bytecode and then executed from there? I know that normally PHP recompiles each file with each request, but even when you bring APC (a bytecode cache) into the picture, the performance is nowhere near that of Java o...

PHP GD2, Convert resource image to 24-bit BMP

Hi. I need to convert resource image to 24-bit BMP image with GD2. This code creates 32-bit BMP image, but I need 24-bit. Help please. function imagebmp(&$im) { if (!$im) return null; $w = imagesx($im); $h = imagesy($im); $result = ''; if (!imageistruecolor($im)) { $tmp = imagecreatetruecolor($w, $h);...

php variables for all functions?

Hi, I am creating a php page with alot of functions which require to use the same variable (session id). Am I able to write $ID = $_SESSION['ID']; and just use 'ID' in each function? Rather than having to write $ID = $_SESSION['ID']; in each function? Thanks ...

Built in classes on php.net

I know this is very newbyish but I have been using php.net for refernce for at least 2 years now to look up the built in functions and I am just noticing that there is some built in classes as well like here for an example http://www.php.net/manual/en/datetime.settimezone.php I am now remembering seeing some functions in the past that w...

Is it bad to use autoloading in PHP?

From php.net... In PHP 5, this is no longer necessary. You may define an __autoload function which is automatically called in case you are trying to use a class/interface which hasn't been defined yet. By calling this function the scripting engine is given a last chance to load the class before PHP fails with an error. Now I am wantin...

Search Engine with spiders

I need to write a small search engine with spiders and all this stuff.What do you recommend men ASP.NET or PHP ? and what sources should i read in to get the knowledge? ...

Redundancy in PHP??? safer or unnecessary

I'm using the MVC model (I think thats what its called) and I have seperated my site into smaller pages and includes.... I was wondering If its safer/better or worse (with no benefit) to check the same conditional twice... for example I have an accounts page that looks something like this // Must be logged in if(isset($_SESSION['userID...

How can you make a PHP application require a key to work?

About 4 years ago I used a php product called amember pro, it is a membership script which has plugins for lie 30 different payment processors, it was an easy way to set up an automated membership site where users would pay a payment and get access to a certain area. The script used ioncube http://www.ioncube.com/sa_encoder.php to pre...

Cleaning up this PHP Markov Chain output?

This is my first time working with Markov chains. I want to combine two sources of text and get a readable Markov Chain. The implementation I'm using is here - the sources of text are stripped of markup, etc. I was first exposed to Markov Chains with the Ruby Rbot IRC bot. Their Markov plugin source is here. I'm finding my use of the...

using curl to cronjob a url

Hi , I have an application on php-Codeigniter hosted on MediaTemple and I want to have a cron job runing a controller, the support told me to use CURL I tried using without any succes, example: curl http://mydomain.com/admin/action/get My controller inserts some information to a database, the curl doesn't display error but the ins...

Can you "compile" PHP code?

I know that PHP is compiled to byte code before it is run on the server, and then that byte code can be cached so that the whole script doesn't have to be re-interpreted with every web access. But can you "compile" php and upload a binary-ish file, which will just be run by the byte code interpreter? ...

PHP time ahead of MySQL time

I run PHP and MySQL on the same machine, but both report different times. I set the timezones by the following methods: PHP: date_default_timezone_set('Asia/Kuala_Lumpur'); MySQL: SET time_zone = "Asia/Kuala_Lumpur"; The difference between two times is always exactly 24 seconds. Any idea why this is happening? I thought the times...

What checks to use to prevent direct access to pages (using PHP)?

Is it better to check for a defined constant, check the url, or any other ways.... something like if(!defined(INCLUDED)) of if($_SERVER['REQUEST_URI'] == $_SERVER['PHP_SELF']) What ways do you check if a file was accessed directly..also, is it important to prevent direct access to pages... (I figure a site should work in the way i...

Cakephp: can Model->find('all') return results without model name

Using Model->find('all') returns an array with the following structure: array( 0 => array('Model1' => array(/* Model1 fields*/), 'Model2' => array(/* Model2 fields*/), ...), 1 => array('Model1' => array(/* Model1 fields*/), 'Model2' => array(/* Model2 fields*/), ...), ...) When a single Model is queried (i.e. Recursive = -1), is...

How does LinPHA populate table?

(I've spent hours looking, and I'm sure it's obvious, but I don't see it...) I've been playing with the open source image gallery LinPHA. It allows you to ftp images to a subdir called albums, and somehow it populates a table called linpha_photos from the files in this directory. I simply can't find the code that (I assume) scans that d...

CakePHP authentication and the User model

I'm working on integrating authentication and authorization into my CakePHP application now and am having some difficulties. First up, I'm not using ACL. It scares me. In my AppController I have this: var $components = array("Auth"); So, any time I want to check the logged in user, I call this from one of my controllers: $this->Aut...

couple of questions about OO and classes in PHP

I am learning about OO and classes, I have a couple of questions about OO and classes in PHP As I understand it, a class that extends another class simply means that the class that extends the other class has access to the variables/properties and the functions/methods of the class that it is extending from. Is this correct? I know tha...

PHP REGEX: Pls help me build the proper regex for this:

Say I had this piece of HTML for example: <div id="gallery2" class="galleryElement"> <h2>My Photos</h2> <div class = "imageElement"> <h3>@Embassy - VIP </h3> <p><b>Image URL:</b> <a href = "http://photos-p.friendster.com/photos/78/86/77426887/1_119466535.jpg" target = "_blank">http://photos-p.friendster.com/photos/78/8...