php

Is it possible to not use { } in PHP?

I fell in love with Python syntax of not using { } but indents instead. Is it possible to config PHP to not use { }? ...

Dual AJAX Requests at different times

Alright, I'm trying to make an AJAX Chat system that polls the chat database every 400ms. That part is working, the part of which isn't is the Active User List. When I try to combine the two requests, the first two requests are made, then the whole thing snowballs and the usually timed (12 second) Active User List request starts updating...

Fill CSS box with text from MySQL till there is no overflow, scrollbar, or hidden text

I want to fill a CSS box with text till there is no overflow or scrollbar. I fetch text from MySQL. The user clicks a button and the next bit of text that can fit will fill the box. The only way I've figured to do this is by parsing through the text and counting characters and newlines, etc and calculating whether it will fit in the b...

Parsing EXIF's "ExposureTime" using PHP

Re, One photo with exposure being 1/640 has the EXIF field of "ExposureTime" eq. "15625/10000000". I am not sure why some photos display this value in a readable format (e.g., "1/100"), but I need to convert this "15625" back to "1/640". How? :) Thanks. ...

Evaluating php generated javascript "inline"?

If you look at the source of this page http://kingston.talking-newspapers.co.uk/ you will see a large amount of inline javascript near the top. I don't really want all this extra stuff floating around in my page source, I'd much rather get it off into a script tag, and then I can minify it and all sorts. If I call it as a php file, thi...

Prevent XSS but allow all characters?

How can I prevent XSS but allow any characters to be used? Like I can post HTML code on a forum like <html><body><h1>Test</h1></html>, but it would not be rendered in the browser as html? How can I do this so it does not convert the characters in PHP? ...

File streaming in PHP - How to replicate this C#.net code in PHP?

I'm writing an interface to a web service where we need to upload configuration files. The documentation only provides a sample in C#.net which I am not familiar with. I'm trying to implement this in PHP. Can someone familiar with both languages point me in the right direction? I can figure out all the basics, but I'm trying to figur...

Best practices for class-mapping with SoapClient

Using SoapClient's class mapping feature and it's pretty sweet. Unfortunately the SOAP service we're using has a bunch of read-only properties on some of the objects and will throw faults if the properties are passed back as anything but null. Need to filter out the properties before they're used in the SOAP call and am looking for adv...

Using PHPUnit to test cookies and sessions, how?

With PHPUnit it's quite easy to test raw PHP code, but what about code that heavily relies on cookies? Sessions could be a good example. Is there a method that doesn't require me to setup $_COOKIE with data during my test? It feels like a hacky way of doing things. ...

property not updating in object when page is posted

Hi I have set a property in a constructor like so function __construct() { $this->count = count(@$_SESSION['filearray']); //count how many files in array } and using it in condition statements if($this->count > 10) //then do something but it appears the count isn't being updated when I use another method of injecting values into thi...

Memcached Latency in Amazon EC2

Hi, I am planning to use Amazon EC2 host only for MemCache.My web application ll be residing on shared hosted server and will be communicating to Ec2 for querying Memcache. How would be the performance of this setup. Regards, Mugil. ...

Regex: Strip non alpha numeric or punctuation.

How can I use PHP to strip out all characters that are NOT alpha, numeric, space, or puncutation? I've tried the following, but it strip punctuation. preg_replace("/[^a-zA-Z0-9\s]/", "", $str); ...

which situation abstract class i should use

Possible Duplicates: What is the purpose of abstract classes? When to use interfaces or abstract classes? When to use both? Hi , Am not worked on extream level of oops in my projects , So i have little doubts , In which situation should i use abstract method or classes , Basically i know about abstract class definition a...

What causes Apache Environment Variable set using mod_rewrite to have "redirect_" appended to name?

I am trying to set Apache environment variables (for use in PHP) with the [E=VAR:VAL] flag on RewriteRule rules in an .htaccess file. I have already discovered the variables are accessed in PHP as server variables $_SERVER rather than $_ENV (which makes a certain amount of sense). However, my problem is for some rules the [E=VAR:VAL] fl...

Which langauge should i use for Artificial intelligence on web projects

I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods. I only know PHP/mysq/JS, and there is not much AI stuff examples in PHP. There are some books on AI on internet but they use Java , Python. Now I have to apply AI techniques on web application. Which languag...

PHP array taking up too much memory

I have a multidimensional array. The array itself is fine. My problem is that the script takes up monster amounts of memory, and since I'm running this on my MAMP install on my iBook G4, my computer freezes up. Below is the full script. $query = "SELECT * FROM posts ORDER BY id DESC LIMIT 10"; $result = mysql_query($query); $posts = ar...

Create table with PHP and populate from MySQL

Hi all, I am creating a table to display on a web page and that table is populated from data in a MySQL database. I am trying to do a couple of things that are making it difficult for me. First I am trying to have call the PHP code that exists in a separate file in HTML via JavaScript. I think I have that working right but I am not 10...

Setting REMOTE_USER for apache logs using php

In mod_perl i can do something like: $r->user("username"); And then the username will show up in the username section in the logs. Is there a way to do this in php? without having to modify apache? Edit: So far i've tried both: $_SERVER['REMOTE_USER'] = "username"; $_SERVER['PHP_AUTH_USER'] = "username"; apache_setenv('REMOTE_USER'...

Station ID - more than IP

Hello I am working on internal PHP application where users login only from our network (we are on dedicated IP and application is checking $_SERVER['REMOTE_ADDR'] and if is match our IP go thru if not - Bye However how I can identify from which station user is login ? Using cookie not gonna work - those are windows station working unde...

Is it possible to use multiple programming languages on one webiste

Suppose i have one webiste with simple pages in php like page1.php page2.php Now there is one page where i want some detailed functioning and i want to use python for that and it will look like page3.py and in other page i want to use java like page4.jsp Provided i have installed python , java on webserver. Is it possible ...