php

Unit of Work pattern, getters, setters and contracts (PHP)

I'm not sure if the title is the best way to describe this question. This book - http://apress.com/book/view/9781590599099 - illustrates an implementation of the Unit of Work pattern. It goes a little something like this. class UoW(){ private array $dirty; private array $clean; private array $new; private array $delete; ...

What does this regular expression mean?

What does this regular expression mean? preg_match("/^obj(\d+)\-{0,1}(|mi\d{0,1}|critical|questionText|answerText\-{0,1}\d+)$/", $k, $a) the preg_match is a php function that should translate it ...

PHP blank body page on first time open on firefox on my development server

Hello all, I really don't know why my web page is always blank in body whenever open a new page in firefox on my development server! My development server have many web sites! Some sites same problem and some sites no problem... But I'm not working with server administration. The result of the page is blank body: ...

how to "one column of table minus 1"?

i have a TABLE named FLY,i have a column in it named FLY_NUM.im trying to decrease the value of this column in a mysql query(in PHP). something like this : mysql_query("UPDATE fly SET `fly_Num` = `fly_Num` -1 WHERE fly_ID ='1' "); this is wrong!everytime this query run,FLY_NUM column set to zero.how can i do such a thing? ...

An easier way to fwrite?

Hi all, fwrite($fh, <?php $fields = array("url", "shoutcast_url", "site_name", "site_subtitle", "email_suffix", "twitter_username", "skype_name", "phone_number"); foreach ($fields as $field) $$field = mysql_real_escape_string($_POST[$field]); mysql_query("UPDATE config SET url='{$url...

One type of delimiter in one date time string in RegEx

Hi all, Is there any way to write a Regex that can validate one type of delimiter in one date time string only? For example, 30/04/2010 is correct but 30-04/2010 is incorrect. I googled and found something about backtrack but I am not very sure how to use it. For example, if i have this regex: (?P<date>((31(?![\.\-\/\—\ \,\–\-]{1...

Restarting Apache should not allow PHP scripts to continue running after?

Hello all, I have a PHP script that is running and I sometimes just want to restart apache and get rid of all running PHP scripts. However, I have noticed after my restart, a PHP script will continue running. Why is this? Is there an option to make sure Apache does a proper restart? Or is the ignore_user_abort function causing this iss...

Non-technical question: Knowledge > experience or experience > knowledge?

So I apologize if I'm posting this in the wrong place but I thought asking the coding crowd would be best. So I'm building a website with 3 developers. One dev is on front-end, one on PHP back-end and one on the database design. The core application of the website is actually much more complicated than i/we (the devs here) originally im...

What is the difference between Switch and IF??

I know this may be simple question but want to know every ones opinion on this. what is the difference between switch and IF function in PHP?? What I can see is where ever "switch" function uses "IF" function also applies there..correct me if I am wrong.. Or any performance wise difference between two?? ...

cache help - php5

Hello all. I have build my own freamwork i now i need to implate a cache system. i read about ( Memcache ) but i need now one think to cache me template system, can sombardy maby help me here to link to nice stuff? :) ...

Simple variable and pixel question

For you guys, I imagine this will be easy. <div class="vote_pct" style="width: $widthpx;"> I want the variable to be $width and for it to have px on the end. If i put a space, it doesnt work. If i put them together, it treats it as one big variable name. Could I ask someone the correct snytax to achieve this? Thanks ...

php safe_mode_exec_dir help

I am hoping to find some more information about this PHP setting, I assume I need to change its value in the php.ini but I set the root the folder as /file/path/ or as http://www.domain.com/file/path? Any advice would be great ...

Emulating Zend Framework's CookieJar

I'm porting over some function using Zend_Http_CookieJar but need some clarification. Presumably the CookieJar only lasts as long as the instance is running. So could I use curl to produce the same thing? : curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefil...

How to detect .NET framework installed in a web page (pure HTML or PHP)

I need to display additional information on a web page (PHP) if one of the following criteria is met: .NET Framework Installed on the client machine in lower than 3.5 Impossible to determine if .NET Framework 3.5 is installed or not on the client machine I know that some browser (if not only one, IE) is sending that information in hi...

PHP: LightOpenID, how to fetch account data from provider?

Hi! I'm having problems with a small OpenID-library called LightOpenID . I can authenticate to almost all providers, but I don't know how to fetch the data from the provider. I only get Array(), eaven with print_r(). ...

Smarty 3 trusted_dir?

Hey Guys I cannot seem to figure out where to set the trusted_dir variable in Smarty 3. Now anytime I use a {insert name="func_name" script="thescript"} I get the error "missing script file". Does anyone out there know how to allow this? $smarty->security is set to false. Thank you. EDIT: As of the posting of this question, this func...

Facebook extended permissions from canvas application

I'm create a Facebook canvas application that will be require extended permissions, for both images (creating galleries, and uploading images) and posting to a users news feed. I'm having trouble with extended permissions. What is the correct way to do this through Javascript or PHP? ...

How do I remove a variable name from a URL using htaccess?

So basically I want users to be able to go to my website with a URL of something like /45678, instead of having to use /?p=45678, so really I just want to remove the variable name. I've tried using mod_rewrite, but it seems that is only for removing the name when the page is visited. Thanks for the help, -Tom Update: Here is the curre...

How to find the extension of an image from path in PHP?

Hi, Is there any standard function in PHP to find only extension of an image from the corresponding file path? For example ff my image path is like '/testdir/dir2/image.gif' then the function should return 'gif'. Thanks ...

string manipulation pre_replace or str_replace

I need to replace a word with another word. But $var= str_replace($linklabel[$k], $linklabelmod[$k], $var); is not giving the desired result. For example i have a string $var="the theory of them thesis"; $linklabel[1]="the"; $linklabelmod[1]="hhh"; What i need is, i just want to replace the word "the". But since "the" is repeat...