php

PHP equivalent of a Ruby assignment idiom

Hello, what's the PHP equivalent of Ruby's "||=" assignment idiom? The scenario is I want to instantiate an object or array "on demand," and not necessarily when a class is initialized. I've tried to find this in the PHP docs, but I'm having difficulty finding things I need in there (miss the Ruby). Thank you! ...

HTML Purifier - what to purify?

I am using HTML Purifier to protect my application from XSS attacks. Currently I am purifying content from WYSIWYG editors because that is the only place where users are allowed to use XHTML markup. My question is, should I use HTML Purifier also on username and password in a login authentication system (or on input fields of sign up pa...

PHP Syntax ${"{$type}_method"}

I've been reading an PHP5 book, and the author commonly used this syntax ${"{$something}_somethingelse"}; I have no idea what that means. Does it dynamically generate a variable name? Someone help me out? ...

Find greatest of three values in PHP

With three numbers, $x, $y, and $z, I use the following code to find the greatest and place it in $c. Is there a more efficient way to do this? $a = $x; $b = $y; $c = $z; if ($x > $z && $y <= $x) { $c = $x; $a = $z; } elseif ($y > $z) { $c = $y; $b = $z; } ...

Why am I unable to use a variable in my require or include statement on XAMPP?

While cleaning up some old php scripts I've noticed some weird behavior with require/include statements when I try to use variables. On the live server, the following code works fine.. <?php $test = "http://localhost/elearning/trunk/mypage.php"; require "$test"; ?> ..but on my XAMPP installation ((basic package) version 1.6.7) I rece...

Pagination for a variable content document

The project is developed using CakePHP. The page is of a news feed article. Pagination is simple when you want to return (x) number of records per page, or (x) number of images per page, or even limit the number of words/paragraphs/characters but what if you want to paginate by the visual length of the page? The issue came up because...

Is this the best way to use memcache?

I just started playing with memcache(d) last night so I have a LOT to learn about it I am wanting to know if this code is a good way of doing what it is doing or if I should be using other memcache functions I want to show a cache version of something, if the cache does not exist then I generate the content from mysql and set it into c...

Get URL for mediawiki page given the Title - programmatically in PHP

Hi, how can I get URL for an Article in MediaWiki given the title? I want to create links to certain pages in the skin template programmatically using PHP right now I am doing this: <a href="<?php $wgScriptPath ?>/index.php/Page_title">Page title</a> Which is a bit too wordy, I'd like something <?php page_link_by_title("Page_title"...

Using mod_rewrite for subdomains

I wan't people to be able to register their own sections within my site, and have those sections be their own subdomain of my site. so someone can register 'test' and have 'test.example.com' refer to their site which would be at say /site.php?id=1 So how would i go about writing a mod_rewrite rule for this? ...

500 Internal Server Error?

Hi,everyone, Recently, I put my project which is php+smarty+mysql in my httpd server. But I encountered an error that says: 500 Internal Server Error My OS is archlinux, and the httpd server and php were installed like this: sudo pacman -S apache php If I use a test native php file which contains the following: <html> <head...

cURL failing when called from PHP exec()

I'm making a call to download an XML file and write it to a file using exec() and the curl command. I tried using curl_exec(), but it wasn't recognized by my PHP system. Somehow, the cURL call now fails. It didn't before, but one day I visit my site and– WHAM. Bye bye XML parser. Things that did work: Calling cURL from the command li...

regex that won't find pattern in alt text for php eregi_replace

I'm wondering what the regex for an eregi_replace would be needed to catch a string that is not contained in an alt attribute. e.g. It should find and replace John Doe in: "John Doe was born on..." but not find/replace when John Doe's in any tag for example: <img src="/jd.jpg" alt="John Doe at the beach" /> ...

php - how to open print window while a pdf file is opened in web page?

I use FPDF to generate a pdf file and open it in a new window. how to pop up the print window when it is opened in a new window? ...

Memcache connection question

Take this code for example $memcache= new Memcache(); $memcache->connect('127.0.0.1', 11211); $rows2= $memcache->get('therows1'); if($rows2 == ''){ $myfriends = findfriend2(); $memcache->set('therows1', $myfriends, 0, 30); }else{ echo '<pre>'; print_r($rows2); echo '</pre>'; } The connection; $memcache->connect('1...

Submitting a Form using PHP and AJAX via jQuery

So I am using "load" functions of jQuery to use ajax on my pages. Can anyone write a small snippet of code using jquery load (or any ajax function which you think is the best) ? What I do is make a form, onsubmit pass to js, further using GET pass values into the load function and return false; though this works I am sure this is not th...

Live HTML & PHP editor/IDE for PC?

Are there any IDEs on PC which will allow you to view your changes live as you are typing? / Can any IDEs you know of be set up to do that? For both HTML and PHP ideally? ...

Facial recognition/detection PHP or software for photo and video galleries

I have a very large photo gallery with thousands of similar people, objects, locations, things. The majority of the people in the photos have their own user accounts and avatar photos to match. There are also logical short lists of people potentially in the photo based on additional data available for each photo. I allow users to tag pho...

How can I protect part of an array in php from being modified?

I have an array in php like this: $myArray = array('name'=>'juank', 'age'=>26, 'config'=>array('usertype'=>'admin','etc'=>'bla bla')); I need this array to be accesible along the script to allow changes in any field EXCEPT in the "config" field. Is there a way to protect an array or part of an array from being modified as if it where d...

Redirect to older page in php?

Lets say, user go to "profile.php" page, but it requires login. Then it redirects to login page. But after login, it should redirect back to profile.php page. How do i do that? How to get current URL in php? $_SERVER['URI']???? ...

I look for the open source Web application that used ZendFramework.

I found "dodo". Please give me informations with it if You know it besides it. ...