php

Delay inbetween two simultaneos php file downloads from the same script

Hi, I have a strange problem here: If I try to download more than one file with the same download script (I've tried 5 different scripts found on php.net), the first goes well but the second has a delay of about 60 seconds from the time of its request. If I cancel the first download, then the second starts suddenly. I've tested direct f...

How can I set variable 'allow_url_fopen' in .htaccess or php file?

How can I on 'allow_url_fopen' in .htaccess or PHP file ? please help me ...

php - when using mysqli_fetch_assoc(result), what happens to the result?

When I have something like this: $row = mysqli_fetch_assoc($result); Does $result now have one less row in it? If I loop mysqli_fetch_assoc through all the $result, will it be empty afterwards? ...

How to implement unique hits on articles

Hi, i was wondering what the best way is to implement a hit counter for articles, products, etc. Now if someone visits the page the counter just adds one in the database. If someone refreshes the page it counts continuously, misleading results, and unnecessary reads, writes. I was thinking of storing their ip, but i don't know how to mo...

PHP: Passing functions to a class

I made a class. I give it some objects (mostly retreived database rows) as input, and tell it which fields it has to show, and which buttons I want. Then it renders a very nice html table! It's pretty awesome, I think. $ot = new ObjectTable(); $ot->objects = $some_objects; $ot->fields = array('id','name','description','image'); $ot->but...

What is the difference between -> and :: in PHP?

Hi, This thing has been bugging me for long and I can't find it anywhere! What is the difference when using classes in php between :: and -> Let me give an example. Imagine a class named MyClass and in this class there is a function myFunction What is the difference between using: MyClass myclass = new MyClass myclass::myFunction()...

How to reduce the number of if-else statements in PHP?

I found that there are many if-else statements, especially nested if else statements, these statements make my code less readable. How to reduce the number of if else statements in PHP? My tips are as follows: 1.Use a switch statement when it is suitable; 2.use exit() statement when it is feasible; 3. Use ternary statement when it is fe...

Find answer to string equation without using eval()

I need a way of taking an equation given as a string and finding it's mathematical answer, the big caveat is that I can't use eval(). I know the equation will only ever contain numbers, the four mathematical operators (i.e. * / + -) and parentheses, it may or may not have spaces in the string. Here's a couple of examples. 4 * 4 4+6/3 (...

Is there any alternative for the function file_get_contents()?

In my web hosting server, file_get_contents() function is disabled. I am looking for an alternative. please help ...

How to prompt user to download the PDF file instead of opening?

in my project site if i click on a link and the PDF opens in a new or parent window. Well I want a box to appear that prompts the user to download the file instead of opening it. Does anyone know of a simple JavaScript onClick event that will do this? In all browser default with default settings. EDIT: sorry my server was PHP based ...

How to trigger a URL using php?

I want to trigger a URL without user interaction. I used file_get_contents($myurl); But in my webhost file_get_contents() is disabled. how to do that. I dont want to read the contents of the URL. I just want to trigger the URL. Also I can not use header() function, because, Im going to trigger the url in a loop, so header will not be ...

Problems with character encodings in LAMP app - UTF-8 or not?

I'm still learning the ropes with PHP & MySQL and I know I'm doing something wrong here with how character sets are set up, but can't quite figure out from reading here and on the web what I should do. I have a standard LAMP installation with PHP 5, MySQL 5. I set everything up with the defaults. When some of my users input comments to ...

PHP Mass Email Best Practices? (PHPMailer + Gmail)

Hey everyone, I'm thinking about how to handle sending large amounts of email from my web applications, and whether there are any best practices for doing so. StackOverflow is already labeling this as 'subjective', which it may be to an extent, but I need to know the most successful way to implement this system, or whether any standardi...

Pagination - Removing a large space between bottom of rows and pagination links

Hello, The pagination below works well. It splits a table into 25 rows per page. However, when I click on a page besides page one, there is a large space between the bottom of the 25 rows and the pagination links. I think the problem is related to the CSS. How can I get rid of this large space? Thanks in advance, John /****** bu...

I want to ask which is a better free web host provider with allow_url facility enabled. Where should i ask this question

I want to ask which is a better free web host provider with allow_url facility. I know this is not right place to ask this. where should i ask this ...

cURL: How do I know if my cookies are being set properly?

$ckfile = tempnam ("/tmp", "CURLCOOKIE"); $useragent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"; $ch = curl_init ("website.com"); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setop...

php Array Initialization

Hi, I need to initialize an array of objects in PHP. Presently I have the following code: $comment = array(); And when i am adding an element to the array public function addComment($c){ array_push($this->comment,$c); } Here, $c is an object of class Comment. But when I try to access an functions of that class using $comment,...

Get keyword from a (search engine) referrer url using PHP

Hi, I am trying to get the search keyword from a referrer url. Currently, I am using the following code for Google urls. But sometimes it is not working... $query_get = "(q|p)"; $referrer = "http://www.google.com/search?hl=en&q=learn+php+2&client=firefox"; preg_match('/[?&]'.$query_get.'=(.*?)[&]/',$referrer,$search_keyword); ...

grouping in front of positive lookbehind not matching

Hi Take the following code: $target = 'NAME FUNC LPAREN P COMMA P COMMA P RPAREN'; //$target = 'NAME FUNC LPAREN P RPAREN'; //$target = 'NAME FUNC LPAREN RPAREN'; $pattern = '/(?P<ruleName>NAME )?(?P<funcName>FUNC )?(?:(?<=LPAREN)(?: (?P<arg1>P))|(?P<args>P)(?=(?: RPAREN)|(?: COMMA)))/'; preg_match_all($pattern,$target,$matches,PREG_O...

Should I pursue Java or PHP for a career path in programming?

I've spent the last eight months working in the LAMP stack. Since I just graduated college with a degree in Computer Science, I'm still very new to programming. I've looked at the trends, and for non-Microsoft development stacks, Java and PHP top the list. Given that most of the Java positions in my area (Toronto, Canada) are for S...