php

php includes is there any way to include a file relative only to that document?

If I have an index.php file that includes inc/footer.php I would write: include 'inc/footer.php'; If I want to include another file inside footer.php, I must do it relative to the index.php file (the one that is including it). This may not be a problem, but what about if I want to include index.php from an entire different location? ...

combine two arrays

Possible Duplicate: Elegant way to merge two arrays as key value pairs in PHP? I have two arrays: Array ( [0] => A [1] => B [2] => C [3] => D [4] => E ) Array ( [0] => APPLE [1] => BANANNA [2] => CRANBERRY [3] => DURIAN [4] => EGGPLANT ) I want to combine them so that first value of th...

Code Layout for getters and setters

I am writing a class that has lots of getters and setters and was wondering on what people thought about the following: The normal way is to code like the following: public function setChangeSort($changeSort) { self::$changeSort = $changeSort; } public function getChangeSort() { return self::$changeSort; } What are your opin...

Should class method code be accessing external variables directly?

I have certain PHP class methods that access external variables. These variables are not passed as arguments, but rather directly used by the code in the methods. One method uses a variable that is DEFINEd in a config file and whose purpose is to be available to every part of the app that needs it. This seems ok to me. The other method...

number range in a regex

I may have a hole in my regex knowlege. If I am trying to look for items in a string which may be in the numeric range "item[355-502]" is there an easy way to do this. as far as I can tell I would have to do something like (35[5-9]|3[6-9][0-9]|4[0-9][0-9]|50[0-2]) I know this also matches for 3550-5020 etc, that should be fine Thi...

User Input filtering in PHP

Hello guys, Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT_QUOTES) to process user's posts and comments. Now, i want some certain html tags ignored. such as <b><br /> and a few...

moving around uploaded files in PHP

Hi, I need to resize an uploaded image. The class that resizes needs to get the location of the image to be worked with. It returns the image in a variable. However, when I try to get the path to the image, I get from $_FILES['profile_upload']['tmp_name'] the following: C:\xampp\tmp\php1C5.tmp I don't get the actual file, even though t...

Zend Framework 1.8 Autoloading Zend_Gdata_YouTube VideoQuery.php

I'm having issues with Zend_Gdata_YouTube. It seems unable to locate the file VideoQuery.php despite the fact it is one of the directories mentioned in the warning messages. Also I created a standalone version of the example just including 'Zend/Gdata/YouTube.php'. This works fine. I've dropped the error messages then the class follo...

How to stop sending email in php?

I have a list of email addresses, which I tested that they are invalid, not exists. But my mail server still keep trying to send email to them. Is there any way to stop sending email to the non-exists, invalid email addresses? I am using php though.. ...

How can I authenticate a user session across servers ?

Problem: A download link should be displayed in a user's home page. That download link should ONLY be accessible if the user logged in. But the real problem is that the user's home page and the download link are on separate web servers. Is there a way I can send a token with the download link and validate it there? ...

Regex for finding valid filename

I want to check whether a string is a file name (name DOT ext) or not. Name of file cannot contain / ? * : ; { } \ Could you please suggest me the regex expression to use in preg_match()? ...

What is the use of @ symbol in php?

I have seen using @ in front of certain functions like following: $fileHandle = @fopen($fileName, $writeAttributes); What is the use of this symbol? ...

function sending email twice

I have the following function sending an email twice (and I believe running if($result) twice). it is called on a separate page : <?php $User = new User(); $User->ValidReg(); $valid = $User->ValidReg(); if ($valid === false) { Here is the function in its class: public function ValidReg() { if ( !empty($_POST['username']) ...

$_SESSION variables not transferring from page to page

Hi, If I write the following code: session_start(); $_SESSION['user_id']='daniel'; the variable stays fine as long as I'm on the page on which it was created, and the second I try to call $_SESSION['user_id'] from another page, I don't get a response. Can anyone tell me what mistake I'm making? ...

How do I send an email with PHP?

Possible Duplicates: how to send email with graphic via php how to send mail using php? <?php $error_occured = "no"; $name = $_POST['name']; $b_name = $_POST['b_name']; $number = $_POST['number']; $email_address = $_POST['email']; $situation = $_POST['situation']; $checkup = $_POST['brand_checkup']; $bb_workshop = $_POST['BB...

How to obtain anchor part of URL after # in php

While using LightBox mechanism in my project I got an URL http://nhs/search-panel.php#?patientid=2 I need to collect that patientid from this through GET mechanism, Is that possible in PHP? ...

Application developers wanting to start web development?

So what's your best advice for someone who knows application side development (C++/C#) and wants to start developing web applications and websites? What languages should i start with? (php/javascript/other) What kind of tips do you have for me? ...

Mapping PHP and Flex Objects.

I am using ZendAMF for remoting. <?php error_reporting(E_ALL | E_STRICT); //error reporting, not needed require_once "Zend/Amf/Server.php"; //the zendAMF server require_once "process.php"; //our test class $server = new Zend_Amf_Server(); //declare the server $server->setClass("process"); //load our test-class t...

N-grams: Explanation + 2 applications

Hello! I want to implement some applications with n-grams (preferably in PHP). Which type of n-grams is more adequate for most purposes? A word level or a character level n-gram? How could you implement an n-gram-tokenizer in PHP? First, I would like to know what N-grams exactly are. Is this correct? It's how I understand n-grams...

Posting data through hyperlinks

I want to post ($_GET as well as $_POST) data by clicking on links (enclosed with <a>) and not the regular form 'submit' button. preferred language : PHP I have seen this in a lot of todays websites, where forms are submitted by clicking on buttons looking like hyperlinks. so was wondering how it could be done. Thanks in advance ...