php5

How to programatically change every method to return $this (except predefined list)?

I have a class: class Module { public function a(...params...) { //do something, doesn't return anything } public function b(...params...) { //do something, doesn't return anything } public function c(...params...) { //do something, doesn't return anything } public function get...

PHP Memory Exhaustion error, poor code or just increase memory limit?

I am trying to read 738627 records from a flat file into MySQl. The script appears to run fine, but is giving me the above memory errors. A sample of the file is: #export_dategenre_idapplication_idis_primary #primaryKey:genre_idapplication_id #dbTypes:BIGINTINTEGERINTEGERBOOLEAN #exportMode:FULL 127667880285760002817317350 127667880285...

file_get_contents create file is not exists

Is there any alternative to file_get_contents that would create the file if it did not exist. I am basically looking for a one line command. I am using it to count download stats for a program. I use this PHP code in the pre-download page: Download #: <?php $hits = file_get_contents("downloads.txt"); echo $hits; ?> and then in the dow...

How do I skip a process or function if it doesn't give a result within fixed time??

In PHP I have seen that if a certain process or function isn't completed then the entire application which includes that function get delayed due to that. Say there is a search function which returns lots of result which includes more than 20 functions. An "x" function is taking too much time, hence the result page is getting delayed du...

What is the meaning of the PHP code "<?=$List?>"?

I knew there are two ways to represent PHP code start/end. <?php ?> and <? ?> In this code snippet: <?php for($x=5;$x<25;$x=$x+5): $List .= '<option value="'.$x.'">Greater than '.$x.'% increase</option>'; endfor; ?> <html> ... <select name="growth" id="growth"> <option value="">Choose one</option> <?=$List ?> </select> .....

What is the usage of ":" in if and else statements?

I saw the following code snippet: <?php if(!empty($_POST)): // case I: what is the usage of the : if(isset($_POST['num']) && $_POST['num'] != ''): $num = (int)$_POST['num']; .... if($rows == 0): echo 'No'; else: // case II: what is usage of : echo $rows.'Yes'; endif; I would like to know what the usage of ":" in php code is. ...

function call 'clear_all_cache' and 'clear_assign' is unknown or deprecated. error in smarty?

I need to remove the cache when a user change language, but I get an error message. $smarty = new Smarty; //$smarty->force_compile = true; $smarty->debugging = true; $smarty->caching = false; $smarty->cache_lifetime = 120; if (isset($_COOKIE['country'])) { $country = $_COOKIE['country']; $language = "eng"; if ($country ...

PHP web development

I want to write an app for facebook. Googling suggest me that the best language and technology will PHP. But the thing is I have never develop anything on PHP. My Question is which PHP version I should. Which IDE, where to start web development and where to start facebook API ...

Trying to remove "»" with php

I'm trying to remove this character, and this character only from a $string with php. I've tried str_replace("»","",$test) and str_replace(chr(187),"",$test) but they can't touch it. The issue is it isn't in the same spot every time, so I can't even get creative with trimming the ends Any help? ...

which is better single query or multiple query??

I do have 8 tables. when a query fires from search page data from all these 8 tables is pulled out and displayed on the result page. What I want to know is which is the best optimized query method for this process?? what I do now is : $result = mysql_query("SELECT * FROM TG_dat,TG_dat1,TG_dat2,TG_dat3 WHERE TG_dat.web = TG_dat1.web A...

How do I detect subdomain and filter it??

I do have a domain search function. In search box you have the option to enter any kind of domain names. what I am looking into is how do I filter sub domain from search or else trim sub domain and keep only main. for example if a user entered mail.yahoo.com then that to be convert to yahoo.com or it can be omitted from search. How ca...

FPDF issue while generating pdf with images due to PHP 'allow_url_fopen' setting

Hi, I am facing a problem with FPDF while generating the PDF file with images as explained here. Finally I found the reason for this issue but I am not sure how to fix that one, can anybody suggest some good solution to handle that issue. This problem is due to the allow_url_fopen setting of my server, if I enable that setting then the...

How can I make a function that repeats itself until it finds ALL the information?

I want to create a PHP function that goes through a website's homepage, finds all the links in the homepage, goes through the links that it finds and keeps going until all the links on said website are final. I really need to build something like this so I can spider my network of sites and supply a "one stop" for searching. Here's what...

what is the fastest method to check if given array has array or non-array or both values?

We gave a given array which can be in 4 states. array has values that are: only arrays only non-arrays both array and non array array has no values ...

how to force preg_match preg_match_all to return only named parts of regex expression

example: <?php $string = "This is some text written on 2010-07-18."; preg_match('|(?<date>\d\d\d\d-\d\d-\d\d)|i',$string,$arr_result); print_r($arr_result); ?> returns: Array ( [0] => 2010-07-18 [date] => 2010-07-18 [1] => 2010-07-18 ) but I want it to be: Array ( [date] => 2010-07-18 ) in php's pdo object there ...

PHP Implode Associative Array

Hi All, So I'm trying to create a function that generates a SQL query string based on a multi dimensional array. Example: function createQueryString($arrayToSelect, $table, $conditionalArray) { $queryStr = "SELECT ".implode(", ", $arrayToSelect)." FROM ".$table." WHERE "; $queryStr = $queryStr.implode(" AND ",$conditionalArray); /*NE...

How can I get the value of an HTML element using PHP and XPath?

I have a whole HTML string that is being evaluated using PHPDom and it's working perfectly, except I don't know how to do this one thing that seems really basic. I need to select an HTML element via XPath and have that element's content returned as a string. So far, this is what I have. Can anyone point me in the right direction as to ho...

re-serialize? array

i have this array: [2] => Array ( [type] => jpg [name] => 25.jpg ) [3] => Array ( [type] => jpg [name] => 26.jpg ) [8] => Array ( [type] => jpg [name] => 27.jpg ) [13] => Array ( [type] => jpg [name] => 10.jpg ) [14] => Array ( ...

Get MD5 Checksum for Very Large Files

I've written a script that reads through all files in a directory and returns md5 hash for each file. However, it renders nothing for a rather large file. I assume that the interpreter has some value set for maximum processing time, and since it takes too long to get this value, it just skips along to other files. Is there anyway to g...

Return - Method Chaining ....

I have this code: $db->get()->query() Now i want the get method's return to depend on: $db->get() return $db->query var; but $db->get()->query() the get() method will return $this ...