php5

Using custom classes in Kohana 3

Hey, I'm creating a Call of duty 4 Server Watcher in Kohana 3, and I had created the basic classes for it before: A static Socket class (for handling basic network commands) A Cod4Socket class, (which uses the previously mentioned Socket class) that provides wrapper functions for basic commands. What I want is to be able to use said ...

What language is the Facebook Questions application written in?

What languages are Facebook Questions coded in? PHP? What else? ...

php if not statments

So this may be the way my server is set up but I'm banging my head agianst the wall. What I'm trying to do is say that if $action has no value or has a value that is not "add" or "delete" than have an error else keep running the script. However, I get an error no matter what $action is. $action= $_GET['a']; if((!isset($action)) || ($a...

PHP OOP working with a hierarchy of objects

Hi everyone, I have a Site object but I can't figure out how best to store a collection of Page objects on Site. The pages are hierarchical (a tree structure for a website navigation). I thought about a tree-like array of pages but that would be a pain to interact with - e.g. $site->pages[0][3][1]->addContent('<h1>lol</h1>'). I could us...

alert for new update in php or javascript

How to change background color for last render row in while loop .... that is row1 row2 **row3** If row4 is added then it should row1 row2 row3 **row4** that is star represents some bgcolor red... this loop am following,,,, $i = 1; while ($row = mysql_fetch_assoc($sql)) { $out_data[] = "<p>$i {$row['news']} </p>"; $i...

Chaining method PHP

<?php $sth = Framework::blah()->any_key['any_key_2']; ?> Hello, I want to get 'any_key' and 'any_key_2' in blah(), how I do that? ...

How to get rid of error messages with PHP's imap_fetchstructure()?

Hi! PHP provides very useful functions to fetch emails from a POP3 account, in my case to handle bounce-mails. The function imap_fetchstructure(), however, gives me headache. When using it in one script, I (for some mails) get the message: Notice: Unknown: Warning: MIME header encountered in non-MIME message (errflg=3) in Unknow...

Declaring protected variables in methods

I've had a good look round and can't seem to find an answer to this problem. Basically I'm using the _call method to dynmically generate get and set methods, however when declaring a variable PHP's default is public. Is there anyway to declare a variable from within a class as protected? function __call($method, $arguments) { $pref...

Why does Drupal Page give me a Fatal Memory Error after switching to FastCGI with Apache2?

My site was working fine until I followed this guide, http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-ubuntu-9.10 to set up mod_fcgid and php5. My php.ini in every place has a memory limit of 96MB. The front page of my site (which is Panels / Views) still states, even after flushing cache, and disabling the re...

Insert string into other string

Hi, is there any function to insert string1 into another string2 if known particular insert place of string2. For example I have HTML code about 2000 chars long. And at 1000 char I want to insert other string which is 200 chars length. Your help would be appreciated. ...

Maven PHP project compile = "Execution of php failed. Maybe the php.exe is not in path"

Trying to create a Maven PHP project (just test) for Sonar Generated empty project with mvn archetype:generate -DarchetypeGroupId=org.phpmaven -DarchetypeArtifactId=php5-web-archetype -DarchetypeVersion=1.0 -DgroupId=org.sample -Dartifact=my-app Then trying to compile empty test project with mvn clean compile -e And get...

find caller script path from a library

When execution a script that includes a library, I whant to find from whithin the library the caller script, in Perl I'm using env: $0 that gives me the path to the caller script. In PHP __FILE__ gives me the current script, so in the library it gives me the library path not the caller script path. from perl documentation: $0 Contains t...

compare date trimming

I have a field (nonTimeStampDate) that has date like this 2010-03-15 and I want to check it against another field (timeStampDate) which is 2010-03-15 15:07:45 to see if the date matchs. But as you can see since the format is different it doesnt match even though the date is same. Any help will be appreciated. thanks ...

Replace same character several times with different string

Hello, I have a string with the same character in it several times and I want to replace each occurrence of this character with a different string from an array. I.e. just like in prepared statements: String: "SELECT * FROM x WHERE a = ? AND b = ?" Array: ['alpha', 'beta'] Result: "SELECT * FROM x WHERE a = alpha AND b = beta" Is the...

PHP dynamic object property is there a way to make it work?

So I know I can do something like this in PHP: <?php $x = 'a'; $a = 5; echo $$x; Which will output 5; But it doesn't work with objects/properties. Is there a way to make this code work? <?php class FooBar { public $foo; public $bar; public function __construct() { $this->foo = 'foo'; $this->bar = 'bar'; } } ...

How to append a variable to all the javascript files before they are loaded in a page in cake php?

Hello friends, I need to append a variable to all Javascript files while they are included in a page automatically. The variable needs to be added before the page gets loaded. Following is the example of what i need. var scriptfile='http://www.whatever.com/myjs.js?rnd='+revision_number I need to achieve this using Cake PHP. Please g...

array replace function not working for me

is there any array replace function in php .. in php manual there is a function called array_replace but its not working... Tell me some example... for array replace.. ...

preg_replace remove only part of a string but leave the rest using PHP

I am trying to do a replace within a string in PHP. How do you delete the part that is only in the group in PHP? <font.+?(size.+?.)> I want to remove size=x where ever it in. The problem is I cannot get the $text = preg_replace("<font.+?(size.+?.)>","",$text); function to work. Example source of this <font style="background...

Whats wrong with this regular expression?

I have the following regular expression to find word in text and highlight them Using the word surface for testing purposes. /((?<=[\W])surface?(?![\w]))|((?<![\w])surface?(?=[\W]))/iu It matches all occurences in the following text. surface-CoP-20-70-0000-04-02_Pre-Run_Tool_Verification_Programming_and_surface_Tare surface_revC.pdf...

Trim leading and trailing white spaces in JSON values

All, I make a JSON request to a web server using PHP and it returns me a JSON response in a variable. The JSON response will have lots of keys and values. I would like a function which trims leading and trailing white spaces in each "value" of the key-value pair for the entire JSON response. How can I do that through PHP? Ex: json_dec...