php5

Why isn't my editor highlighting all of my PHP code?

In my code editor, it normally displays PHP code in bold blue print. I'm finding some of my code is not showing up as bold blue print. Can someone please look at the code below and tell me if I'm doing something wrong? Thanks in advance. <td class="hr"><?php echo htmlspecialchars("payroll number")."&nbsp;" ?></td> <td class="dr"...

How to use anonymous functions in PHP5.3

I recently really wanted to us anonymous functions in PHP. Unfortunately my host is still on 5.2. I automatically thought this would work: uasort($array, function($a, $b) { return $a > $b; }); Is this how they work? Simply passed in as an argument instead of a callback? The docs don't say specifically that's how they do, but I hav...

finding image of the remopte url using preg_split

Hi All, i want the content inside of the "img" tag from the string. for ex:- if str="< img src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg" title="Commonwealth Games" alt="showreel" class="clear-right-margin" />" then i want to o/p using preg_split as follows:- src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg...

Why is the php assignment operator acting as an assignment by reference in this case?

I have some code that appears to behave differently between php4 and php5. This code below: class CFoo { var $arr; function CFoo() { $this->arr = array(); } function AddToArray($i) { $this->arr[] = $i; } function DoStuffOnFoo() { for ($i = 0; $i < 10; ++$i) { ...

best way to transform a string to array.

I have an array $AR I have a string "set[0][p1]" When given this string, I need the best way to access the array at $AR['set'][0]['p1'] I have total control on that string, so I need not to worry from injections and stuff, and I can be sure it will be well formatted. There is no way I can put the p1 inside ' to be "set[0]['p1']" ...

PHP / SOAP - trying to learn, but having a problem with implementation

Hiya, I'm trying to teach myself SOAP, just to extend my skillset a bit, but I've hit a wall and I was wondering if a kind developer out there can help? I've set up my server thus: http://www.domain1.com/server.php <?php // Pull in the NuSOAP code require_once('soap/nusoap.php'); // Create the server instance $server = new soap_serv...

CakePHP and HABTM Model Limit Error

I've got a series of Post models that hasAndBelongsToMany Media models. In certain function calls inside of the Post model, I don't need to retrieve the entire list of Media models. However, when I use the following code: $this->unbindModel( array('hasAndBelongsToMany' => array('Media')) ); // Rebind to get only the fields we need: $t...

encoding problem on file_get_contents

i'm using a script for getting a url's content then it calculates keyword destiny etc. but my problem is that, there is problem about turkish characters like "ı","ş" i tried iconv for converting utf-8 to iso-8859-9 but it didn't work. you can see the code on http://www.gazihanisildak.com/keyword/code.txt thx in advance. ...

FileMaker 9 & PHP API - Total record count?

The only way I can see to get a total record count necessary for setting up some sort of pagination mechanism would be something like: $fileMakerObj = new FileMaker( /* credentials redacted */ ); $fc = $FileMakerObj->newFindCommand('someLayout'); //Get max Record count for someLayout $fc->setRange(0,0); $result1 = $fc->execute...

How to run a php script in the background in another php script (like an update button)

How would I go about running a php script when I pressed say an "update" button, in which then it would run say script x1.php (which has no echo's or or other output, successes or failed) then update the current page (I know the update part can be done with ajax, but im not sure how and how I would get the x1.php script to run in the bac...

How to add attributes to soapVars

Hi, I'd like to create soapVars with attributes like this: <tag attr="xxx">yyy</tag> Is this possible with the SoapVar constructor, but without using XSD_ANYXML and raw xml strings? Thanks! ...

Dependency injection when you have no control over instantiation and usage

How is it done? I have a Model class that is the parent to many sub-classes, and that Model depends on a database connection and a caching mechanism. Now, this is where it starts getting troublesome: I have no control over how each object gets instantiated or used, but I have control over methods that get used by the sub-classes. Curr...

PHP session_start() causing HTTP requests to hang

I have an application I've written in PHP from scratch. I'm using PHP's native session handler functions for handling user authentication and persistence. When testing on the development server, everything is peachy. Authentication, persistence, etc, works fine. When installed on the production server, everything works fine up until th...

Parsing complex multiple XML attributes in PHP5

Hi guys first post on this site so excuse the formatting. I'm new to xml parsing with php and well this xml feed has me stumped. I get using purely element based formats, but attributes this complex not so much. I tried to get the site to change to easier element based format but they're sticking with this format using attributes and I'...

form $_POST as an array

i noticed that when posting a form the fields come out as an array. like if i do if(isset($_POST['submit'])) { print_r($_POST); } what i usually do for form fields is the following. lets say i have something like this (this is how i usually do it) <form method="POST" action=""> <label>First Name: </label> <input type="text" name="f...

Is there any replacement for PHPDocumentor that supports PHP 5.3?

Some of the new PHP 5.3 features, including namespaces and anonymous functions, are not compatible with PHPDocumentor, even with the latest release. For example, it just raises an error when it encounters "a function with no name", i.e. a closure. So, are there any other open-source tools that generate API documentation (preferably in HT...

Cross Domain Single Selective Sign In.

Hi, Its not explicitly cross domain sessions that I am looking for, but its the easiest way to explain what it is I want. I have a system which creates websites. The websites are hosted across lots of different servers. Users can create their account and then they can create lots of websites. They could create www.mysite.com subdom...

Why is $_SERVER['PATH_TRANSLATED'] repeating itself?

I'm trying to create a MVC framework when I noticed the $_SERVER['PATH_TRANSLATED'] variable is doing this: [PATH_INFO] => /test/test2/test3 [PATH_TRANSLATED] => redirect:/index.php/test/test2/test3/test2/test3 This is when I'm accessing the PHP file by http://domain.tld/test/test2/test3 Notice how it is repeating after /test/ T...

inserting data into multiple tables using php via a web form

Hi guys, i have been recently studying php and mysql and also is currently developing a online web form using php and mysql. in the form i have multiple tables that i need to submit data to. i have tried this code; $required_fields = array('event_type','accommodation_type','public_user','comments','grand_total'); $required_fields2...

PHP: translate virtual path to physical path

Is it possible to translate a server relative virtual path to physical path in PHP? e.g. if I have a url: /home/index.php then find the physical path of index.php somehow from some other script?? ...