php

How can I pass variables to a file included in a class in PHP?

So I'm working on my own little MVC framework as a learning exercise. It's working great, but I want to be able to reference variables in my view files without $this. So for example I have a controller object which instantiates a view object. From the controller I pass the variables to the view like this $this->view->foo = "bar"; The...

How can I validate a sentence using PHP and JavaScript?

I am currently trying to validate if the sentence a user enters matches the expected sentence. The expected sentence is stored in a PHP variable $rebuiltSentence, for example 'the cat sat'. The problem is that when I try to call my JavaScript function formSubmit() I need to give it the sentence to check, therefore ideally I would call f...

Fetch the drive contents dynamically

Hi friends in my project i have a situation that when i select the drive letter it display the corresponding files with in the share drive will dispaly . for that i find the connected drives with my system using the following code echo "<select id = 'drives'><option>Drives</option>"; for($ii=66;$ii<92;$ii++) { $char = ch...

Regex to strip comments and multi-line comments and empty lines

Hello, I want to parse a file and I want to use php and regex to strip: blank or empty lines single line comments multi line comments basically I want to remove any line containing /* text */ or multi line comments /*** some text *****/ If possible, another regex to check if the line is empty (Remove blank lines) Is that pos...

symfony Logging

During the day I am a Java developer, but at night I try stopping crime as a PHP superhero. My weapon of choice is symfony. We can say that I am training to be a superhero. In Java, I use log4J, a logging framework. In Log4j you can do something like this: if (log.isDebug()) { // do some expensive operation that should only be dis...

How do we get coders to look up existing functions before writing their own?

Why are so many people still writing crappy versions of things in standard libraries? Not to go after PHP developers, but guys go read the PHP SPL ...

(PHP)choose memcache::connect or memcache::pconnect?

Hi, I'm using php::memcache module to connect a local memcached server (@127.0.0.1), but I don't know that which one I should use, memcache::connect() or memcache::pconnect ? Does memcache::pconnect will consume many resource of the server? Thank you very much for your answer! ...

Zend Form: Add a link to the right of a text field

I realize that I should be able to do this, but what can I say, I don't get it. I've even rtfm'ed until my eyes fried. I learn best by examples, not the deep explanations that Zend's docs give, or the typical "use decorators" response that this type of questions usually produce. What I need is markup like this: <dt> <label for="nam...

Mocking methods used in Static Methods [PHPUnit]

I'm trying to stop a method that sends an email from actually sending the email and I think that mock objects (or some variant) are the way to go. Here is the situation: class UserModel { public static function resetPassword() { // Code to generate new password, etc, etc self::_sendMail($to, $body); return 1;...

Magento Themeing

I've read through all the docs on the Magento E-Commerce website, but I'm still fighting with Magento to get my theme looking just right. I have the basic understanding of the XML file layout files, but all the template code is frustrating me. Can someone explain the basic tags and maybe give a reference or two on where I can learn more?...

php file uploads over 200mb

after changing the max file size, session times, and post max size is it wise to use php to upload files larger than 200mb? reliable? (and this is ignoring whether a client connection is maintained) edit: done through http not ftp ...

What PHP/MySQL book would be good as a textbook?

I'm possibly teaching an undergraduate PHP/MySQL course in the Fall and was wondering if anyone has any recommendations for good textbooks. The books have to be geared towards a beginner/medium level (I'm assuming/hoping my students will have C++ and MsSQL classes prior to mine). Topics I want to cover in PHP: Variables/Constants Con...

Design considerations for internationalization

I've read Joel's article on Unicode and I feel that I have at least a basic grasp of internationalization from a character set perspective. In addition to reading this question, I've also done some of my own research on internationalization in regards to design considerations, but I can't help but suspect that there is a lot more out the...

Can you force symfony resolve to a specific route?

Say that I have to following 2 routes in this order: Zip: url: home/:zip param: { module: home, action: results } State: url: home/:state param: { module: home, action: results } and I use a route such as: '@State?state=CA' Why does it resolve to the Zip route? I thought when you specified the route name explicitly: '@Stat...

Amazon ItemSearch Availability

I'm using the amazon web services and I was just wondering if anyone knew how I could return unavailable items, I don't exactly wish to purchase them, but to collect statistical information out of them so getting items that aren't available would make my searches much broader. $sc = new SoapClient('http://webservices.amazon.com/AWSEComm...

Allow php sessions to carry over to subdomains?

Hello I use php sessions (not cookies, except for session id cookie) for all user data, and when a user goes to their profile user.mydomain.com they are immediately "logged out" untill then remove the subdomain. Is there a way to accept sessions from all domains as long as its *.mydomain.com thanks! ...

Choosing a PHP Debugger

A couple months ago I learned of Xdebug, started using it, and now I can't imagine living without a debugger. Somewhere on SO, I found out about another debugger. Now I'm not sure if I should continue using Xdebug or not. I decided to search the Web for a comparison of PHP debuggers but came back empty-handed. What PHP debugger do you u...

How to draw a graph in PHP?

Hey I want to draw a graph(Stdent mark distribution) in my site based on PHP. How can I do this? ...

using phppas blowfish encryption (used by wordpress)

here is the site http://www.openwall.com/phpass/ whoever is familiar with this class, my question is this i'll be using the class found on that page to hash the password for members. the code declaration looks something like this require_once("password.hash.php"); $blowfish = new PasswordHash(8, FALSE); $blowfish->HashPassword($_POST...

Can you help me make this regular expression?

I have a script where I need to get three parts out of a text string, and return them in an array. After a couple of trying and failing I couldn't get it to work. The text strings can look like this: Some place Some place (often text in parenthesis) Some place (often text in parenthesis) [even text in brackets sometimes] I need to spl...