php5

Private functions can be called publicly if the object is instantiated within the same class

<?php //5.2.6 class Sample { private function PrivateBar() { echo 'private called<br />'; } public static function StaticFoo() { echo 'static called<br />'; $y = new Sample(); $y->PrivateBar(); } } Sample::StaticFoo(); ?> The above code will output: "static called private called" Why doe...

Installing PHP in windows - "php.exe" and "PHP SAPI" both should support pdo_mysql

We use Windows for our development systems. I am installing PHP, Apache, MySQL manually. All from zip packages. Now: If I use php thread safe binaries: pdo_mysql fails to load when executing php.exe from command line. I get the following warning: PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module Module compiled with mod...

preg_match two variables with metacharacters

I have two string variables which are both file paths. The code that worked used ereg which is deprecated, so I'm trying to rewrite it using preg_match: Old code that worked: $path1 = quotemeta($path); ereg("$path1(.*)$", $path2, $matches); Using preg_match which doesn't seem to work: $path1 = quotemeta($path); preg_match("/$path1(....

PHP class method named print... not allowed?

I am writing a Controller for Codeigniter with a method named "print". The name is important, because I would like to be able to access the page at "http://www.mysite.com/mycontroller/print". However, I cannot do this because there is the syntax error: Parse error: syntax error, unexpected T_PRINT, expecting T_STRING Is there any sp...

oci_connect Blank Page in PHP

UPDATE (5/21/2010) SUCCESS! So after MUCH $head->desk()'ing, I've solved it. Remember kids, be wary of the instant client version you use, dependent on the virtualization settings! I had been installing the generic Instant Client (not aware our ESX servers sit on AMD processors, not Intel) and that worked fine internally (the CentOS i...

Creating Excel spreadsheet on the fly with PHP

I'm creating Excel files in a PHP project. Those files aren't just CSV data... They are multiple tabs spreadsheets with functions and formatting. So far I'm using the Spreadsheet_Excel_Writer class that is provided with Pear. Everything is fine but our users don't like 2 things: When they open those files generated by PHP, modify the...

PHP5 __get() best practice

I have a PHP class that stores a complex multidimensional array, and rather than write individual accessor methods as an interface to this array I decided to use PHP5's __get method. As I started to write these magic accessors it donned on me that I had no idea what best practices are here, so I thought I'd ask. Is one large if/else str...

the DOM and XML functions for PHP5?

i've read that you could use the DOMdocument class in php5 to manipulate XML documents. and also the XML functions. where can i find documentation for the DOMdocument class with all its methods? and the same with XML functions? are these the only things i need to learn when handling (creating and reading) xml documents with php5? than...

Using "includes" in an OO PHP Class

I have a class that inserts information into a MySQL database. I have the connection variables set as fields at the top of the class. When I run the class it works perfectly. I would like to simply store the class fields in a separate file (not a class but just the fields saved in a file) and include it inside my class. when I do this ...

PHP FILTER_SANITIZE_URL swedish domain name

I am experimenting with filter_input and filter_var and I am currently trying to sanitize URLs with FILTER_SANITIZE_URL. The test program gets input from a GET variable which consists of a URL, (ex. foo.com/bar.php?a=http://www.domain.se). It works fine as long as I don't use swedish domain names. Ex: (foo.com/bar.php?a=http://www.äta.se...

php 5 strpos() difference between returning 0 and false?

if(strpos("http://www.example.com","http://www.")==0){ // do work} I'd expect this to resolve as true, which it does. But what happens when I do if(strpos("abcdefghijklmnop","http://www.")==0){// do work} This also passes on php 5 because as far as I can work out the strpos returns false which translates as 0. Is this correct thin...

Zend_Form: Add Link before submit-element

I have a little problem, I want to have the link inside the DIV instead before. I want to have it look like: <div class="clear"> <a href="somelink">A link</a> <input type="submit" name="submit" id="submit" value="submit" /> </div> But at the moment it looks like that: <a href="somelink">A link</a> <div class="clear"> <input typ...

const vs static in PHP

IN PHP5 i can declare a const value to a class: class config { const mailserver = 'mx.google.com'; } But i can also declare public static: class config { public static $mailserver = 'mx.google.com'; } In case of a config file which i will later us, like: imap_connect(config::$mailserver ... imap_connect(config::mailserve...

Problem With Zend_Controller_Router Static Route

SOLVED! Here is my route definition in the bootstrap file: $router = $this->frontController->getRouter(); $route = new Zend_Controller_Router_Route_Static( 'tipovanie', array('module' => 'default', 'controller' => 'index', 'action' => 'contest') ); $router->addRoute('contest',...

php4delphi: Trying to supress error using @ on function socket_recvfrom, but ZEND gives a warning anyways! Script then stops!

Hi! I am using php4Delphi in Delphi. In my PHP script I`m using the function: $ret = @socket_recv_from(....); In a normal PHP script ran by either PHP itselfs or Apache this would not give out a warning when the @ operator is present. But with my application it does anyways... I am using PHP version 5.3 and newest release of php4De...

Using php variable inside a query

Hi, i am using a query inside php as $query = 'SELECT * from #__chronoforms_UploadAuthor where text_6 like "%'.$_GET['title'].'%" and text_7 like "%'.$_GET['author'].'%" limit 0,1'; where i am trying to insert a php variable instead of 1 in the limit.. $query = 'SELECT * from #__chronoforms_UploadAuthor where text_6 like "%'.$...

how to use gettext in php?

i have a file dk.po and dk.mo ind folder lang in my webdir. how can i use this file? i have try all, but i can't relly get it to work. pls help me. // Lang putenv('LC_ALL=dk'); setlocale(LC_ALL, 'dk'); // Specify location of translation tables bindtextdomain("dk", ROOT .'lang'); // Choose domain textdomain("dk"); Tanks a lot. ...

Cannot Access the CSS while developing in Ubuntu?

Hi, I am developing a web application using PHP and mysql.I was doing the intial development in a windows machine and now shifted to ubuntu ultimate edition.I installed apache/PHP/Mysql and configured them. I placed my web folder in /var/www and when I give the URL in browser,I am not getting the page with CSS. Not Working: href="./c...

A strange bug, is Mysql asynchronous?

Hello, I have a strange bug. I launch a PHP Unit test Suite. At the beginning, it executes a big query to initialize the database. If I put a breakpoint just after the execution of the sql, there is no problem and my tests pass. If I don't put any break point, they don't pass and say that the tables don't exist! It works as if the s...

Why do I get LNK2005 errors when compiling a PHP extension DLL

Hello! I'm trying to compile a PHP extension in VS2008. It is dependent on 3 other projects which I link statically. It used to work fine when I had all my code in one .cpp file. I separated the code into several files to make it more manageable and now it won't compile. I'm getting several (~100 per file) linker errors, LNK2005 (alrea...