php5

Simple, tricky and interesting questions and exercises for PHP Beginners

I'm giving a small PHP course over the next weekend and i would like to present a few questions and exercises for my students, so they can practice with an objective, a fun one. I already presented the basics for them, now it's time for some action. Any ideas, guys? ...

howto stop apache matching /favicon with /favicon.ico

Hello I have site running with apache mod_rewrite and php In my public_html folder i have diss .htaccess file RewriteEngine On RewriteBase / RewriteRule ^([0-9a-z]+)$ index.php?reurl=$1 this works fine if there are no files in that directory with the same name. so for example /favicon would match the file /favicon.ico and the Rewr...

Get all views associated with controller - Zend

If I'm going about this the wrong way, please let me know and I'll accept that as a potential answer. I have a Zend Framework MVC app that is modular, and in one of the modules the site acts very similar to a static HTML site: Category1_Controller Category1_Subpage_Action1 Category1_Subpage_Action2 Category1_Subpage_Action2...

integration testing command line PHP

I've got a PHP script that runs at the command line, executing classes that are already unit tested with PHPUnit. However, I'd like to verify that the script itself has no logical errors and runs properly. // require classes require_once 'injectedClass.php'; require_once 'DBClass.php'; require_once 'taskEngine.php'; $injectedObj = n...

How to find out class/method/function name from filename and line?

I'm working on an error handler and I find the information I get from debug_backtrace() highly unreliable. I thought of using Reflection, but while it lets one get the filename and line numbers from class and method name, it doesn't seem to allow going the other way. Is there any relatively simple, reliable and reasonably lightweight wa...

Compiling PHP, are these errors ok? (Linux-Debian-PHP5.3.3)

Are these ok? My config line is this: ./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --without-sqlite --disable-pdo --disable-reflection --with-curl --with-mysqli=/usr/bin/mysql_config And the...

clean text string

I need to remove everything (parentheses, punctuation, etc), using PHP, from a text string and leave just text. Someone suggested this: $str= trim(preg_replace('/\s*\([^)]*\)/', '', $str)); Also, if there are words like: Bob's it needs to be cleaned to Bob. I also do not need any numbers, just words separated by commas. Any suggest...

Create link to friend's profile page from news feed array

I'm using the PHP SDK from facebook in my own application. When I retrieve the news feed for my own profile it contains the ID for each friend that has a message on my feed. Can I create a link to each persons profile page from just their facebook ID? Or do I have to make a separate API call for each ID and retrieve their username to cre...

ffmpeg-php to create thumbnail of video problem!!!

Hi, I am trying to use this script to create thumbnail of a video using ffmpeg. At first I used phpinfo(); and I found ffmpeg is installed on my server. Then I copied ffmpeg-php onto my server and run the test file I got to know that many function are working on my server I got output like this Output:- Functions available in /usr/...

remove all local javascript file except external javascript files in php

i am writing a php script that compress local javascript files into one from an html page. Now i want to delete local references except external javascript files. for example, i have following variables. $my_domain = "mysite"; $base_url ="http://www.mysite.com" I want to delete all local javascript references except external. local j...

Searching multidimensional array for values, then outputting other values in array

Hi all, I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommen...

Referencing a parameter in a function directly

I'm trying to edit a piece of code written by a development company, which uses the following construct a lot: $dbcol = grabdata($strSqlB,'','','','','','',2); Is there really not an easier way to do this? The code is completely unreadable. I would have thought that the following would work, and work well for readability: $vars = a...

php5 and namespace?

Hei all. i work a lot in PHP5 but i never relly understand the namespace method in PHP can sombady help me here? i have read on php.net's website its not expalde good enof, and i can't find eks. on it. i need to know how i can make code in sample version. namespace: sample class: sample_class_1 function: test_func_1 class: sample_...

How to extract titles, images and text from any kind of feed ?

Possible Duplicate: Best way to parse RSS/Atom feeds with PHP I want to extract the titles, images and text from any kind of Feed Rss ( feedburner, xml, etc ). How can I do this in PHP ? For example, I want to extract the stuff above from this feed: http://feeds.mashable.com/Mashable ...

Code in plain PHP vs DooPhp

I've seen DooPHP is the world fastest MVC framework and I intend to consider this for building mission critical website which is able to handle over 100,000 concurrent users. I have to build my website from scratch on shared hosting and run CPanel on VPS which use Apache 2.0.x with PHP 5.2.14 and MySQL. Performance wise, does it make a...

auto download zip files script

Hello, I want to write a script that will download zip files from a given url and save it somewhere in my hard disk. URL looks like this. http://localhost/downloads/1 to http://localhost/downloads/1. I am trying it like this <?php for($i=1;$i<=100;$i++){ $zipfile=file_get_contents('http://localhost/downloads'.$i); echo $zipfile...

chat functionality on php application

SO has lot many questions of this type but not able to find correct solution. May be I am missing anything. I am struggling from last few days for finding better option for Chat service. Following thing I have to keep in mind before using any option.. It should be OS independent Installation should be easy Opensource so that can be mo...

can i open the docx file with the php?

hello, first of all i store the docx file in my php program and that time when user press submit button than it would be display a file content. but i dont know how to open docx file from the database using php? ...

recommend php library for parsing and modifying dom

i have to modify dom. i.e. remove few elements and add few. kindly recommend any php library that can parse and modify DOM. ...

How to pass variables to Bootstrap.php

Is there a way how I could pass variables to Bootstrap.php? This is how I bootstrap in the index.php: // let's go! $application = new Zend_Application(APPLICATION_ENVIRONMENT, APPLICATION_PATH.'/configs/application.ini'); try { $application->bootstrap(); $application->run(); } catch (Exceptio...