php5

Unusual OO behavior?

here is some php code: class A { private function action(){ echo 1; } public static function callAction(A $a){ $a->action(); } } $a = new A; A::callAction($a); can someone explain me why does object method is vissible from static method context how does following code works in other languages ??? ...

Have a variable available for class __construct()

I am trying to pass a variable into a class so the __construct() can use it however the __construct() is called before any variables are passed to the class. Is there any way to send the variable before the __construct()? Here is the code: class Controller { public $variable; function __construct() { echo $this->variable; } } $ap...

Easy way to apply a function to an array

I am aware of array_walk() and array_map(). However when using the former like so (on an old project) it failed array_walk($_POST, 'mysql_real_escape_string'); Warning: mysql_real_escape_string() expects parameter 2 to be resource, string given. So I went with this slightly more ugly version foreach($_POST as $key => $value)...

Check when page changed.

Hi, I'm new here, also a novice programmer, and not really familiar with PHP. I don't even know the name of some of the techniques I used when building my apps. I'm sorry for that, but I'll try to explain the best I can. So I'm building a web apps with PHP / AJAX right now, and I've got to the point where some users (with their own priv...

which method is more efficient: set a class property; or return the result?

Please consider this example. (PHP) class Database{ private $result; private $conn; function query($sql){ $result = $this->conn->query($sql); // Set the Database::$result ?? Or return the value and avoid setting property? return $result; // $this->result = $result; } } wha...

is Printer Functions in PHP work in live?

hello all, i used printer functions in php to print the data,it works in localhost, but its not working in live, is it possible to use printer functions in php in live? ...

What is the use of creating functions within functions?

I know that it is possible to create a function within another function. Why might one need to do that in real life? (PHP) function someFunction($var) { function anotherFunction() { return M_PI; } return anotherFunction(); } ...

How to send attachment file?

In php mail() function, how can I send attachments? I didn't find parameter to do this. any help will be appreciated. ...

search big database

I have a database which holds URL's in a table (along with other many details about the URL). I have another table which stores strings that I'm going to use to perform searches on each and every link. My database will be big, I'm expecting at least 5 million entries in the links table. The application which communicates with the user ...

Remove everything from a string expect content between span

Hi, is there any good way to remove everything from a string except the content inside a <span> tag? Example: $myString = "mso:dkdlfkdl */1134*/** <span>Hello</span>"; i want: $myNewString = '<span>Hello</span>'; ?? ...

Hwo to get blog entries from blog namespace show on a DokuWiki start page

A while back I even created a dokuwiki plugin. How do I get blog entries from the "blog" namespace shown on my start page? Does anyone know that? ...

Can I use IF multiple times to switch between multiple options in PHP?

hey i got 9 type on my web. i have to set different keywords each type. with this script; if ($type = movie) { $yazdir = "DVDRip, DVDScr"; } elseif ($type = game) { $yazdir = "Full Version, Patch"; } i can write keywords for two type. how to repeat this correctly for other types? (echo paramether must be $yazdir) ...

how to determine state of DB_DataObject instance?

As I add methods to various DB_DataObject classes, I lean towards Class Example extends DB_DataObject { function methodx() //start fresh { $newObject = DB_DataObject::factory($this->__table); /* do stuff with $newObject */ } rather than function methodx() //use current instance { /* do stuff with $this */ } I've realize...

Connecting to SSH via PHP's exec() function.

I am currently trying to figure out how to connect to another server via SSH using PHP's shell functions. I have a site where I have to pass data from PHP to a custom command line program, then return the output. On the old server I was using, this was possible via the exec() function: $cmd = '/path/to/custom/program "arg1", "arg2", "ar...

Parsing BlogId from Blogspot.com in PHP using Regex

How can i get the blogid from a given blogspot.com url? I looked at the source code of the webpage from a blogspot.com it looks like this <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.blogger.com/rsd.g?blogID=4899870735344410268" /> how can i parse this to get the number 4899870735344410268 ...

How to add a seperator between menu items in PHP but not on the end

I'm trying to put an image as a separator between menu items but not on the outside and I'm not sure how to do this.. So it would end up being something like this: HOME | ABOUT | CONTACT unfortunately my code puts one after every entry including the last one. mysql_select_db($database_db_connection, $db_connection); $query_rsMenu = "S...

List used PHP modules in code base

I need to list all PHP extensions that's required by a given code base. What would be the best way to tackle this problem? My initial thought is to write a script that goes through all files and find all functions and compare them to a given extension/function database. Any other suggestions? Update: I already did some Bash script w...

SQL Server 2005, SQL Driver for PHP v1.1 eats "Transaction doomed in trigger" errors

short version: the sqlsrv driver (Native Client wrapper) "eats" constraint violation errors generated from triggers; the mssql driver (ntwdlib wrapper) reports them just fine. SQL Server 2005 PHP 5.3.1 SQL Server Driver for PHP 1.1 fixture: CREATE TABLE t ( t INT NOT NULL PRIMARY KEY ); CREATE VIEW v AS SELECT CURRENT_TIMESTAMP ...

Invalid controller specified (error) - Zend Framework

Hello, I get all the time this error: exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in blub\libraries\Zend\Controller\Dispatcher\Standard.php:242 I have a file "ErrorController.php" in the "controllers" directory looking like this: class ErrorController extends Zend_Controlle...

looking for advise on importing excel into mysql with php

Alright, see if I can pick your brains from you all. I'm currently working on a project where all the information comes from different clients, the only thing in common is that the received data is done with excel. The excel spread sheet that they present is just a bunch of references and codes, and the problem than I'm facing is that...