Could not convert object to string - php

So I I've tried to make this code log an exception but it gives me the error message object of class domain_model could not be converted to string
The function looks as follows:
function errorLog($log, $error_type, $string, $file, $row, $error_hash, $error_trace)
{
$text = $error_hash . ' (' . date('Y-m-d H:i') . "):\n[Error type]: " . $error_type . "\n[Message]: " . $string . "\n[File]: " . $file . "\n[Row]: " . $row . "\n";
$text .= "[Trace]:\n";
foreach ($error_trace as $t)
{
$text .= ((isset($t['type']) && isset($t['object'])) ? $t['object'] . $t['type'] . $t['function'] : $t['function']) . "\n";
$text .= $t['file'] . "\n";
$text .= $t['line'] . "\n";
$text .= print_r($t['file'], 1) . "\n";
}
file_put_contents(BASE . $log . '.log', $text, FILE_APPEND);
}
After alot of thinking eventually saw that the line in making a mess is infact this one:
$text .= ((isset($t['type']) && isset($t['object'])) ? $t['object'] . $t['type'] . $t['function'] : $t['function']) . "\n";
And as I see it the only one in need of conversion should be $t['object'] however using (string)$t['object'] didn't work and still gives me the same error. Is there any other solution on how to convert it to a string than this?
I've looked at how they suggest it to be done here

Related

Create WSDL File For SoapServer EndPoint PHP File

i wanna create wsdl file for my php end point.
this is my php end point class with two function:
class server{
private $UserIdSender;
private $UserIdReciver;
private $Title;
private $Body;
private $BoardId;
private $obj_ticket;
private $obj_ticket_owner;
private $ticket_id;
public function __construct() {
date_default_timezone_set("Asia/Tehran");
require_once "../../diba-modules/conf.php";
require_once "../../diba-modules/functions.php";
require_once "../../diba-include/entities/ticket.php";
require_once "../../diba-include/entities/ticket_owner.php";
$this->obj_ticket = new \entities\ticket(TRUE);
$this->obj_ticket_owner = new \entities\ticket_owner(TRUE);
mb_internal_encoding("UTF-8");
}
/*public board = 17*/
public function SaveTicketFromPortal($Token,$NationalCodeSender , $NationalCodeReciver , $Title , $Body = "" , $BoardId = 17 ){
$this->UserIdSender = get_id_from_national_code($NationalCodeSender);
$this->UserIdReciver = get_id_from_national_code($NationalCodeReciver);
$this->Title = trim(filter_var($Title,FILTER_SANITIZE_STRING));
$this->Body = trim(filter_var($Body,FILTER_SANITIZE_STRING));
$this->BoardId = filter_var($BoardId,FILTER_SANITIZE_NUMBER_INT);
if($this->UserIdSender <= 0 ){
return array("Success" => "-1" , "Message" => "Sender NationalCode Not Found !" );
}elseif($this->UserIdReciver <= 0 ){
return array("Success" => "-1" , "Message" => "Reciver NationalCode Not Found !" );
} elseif(mb_strlen($this->Title)>500){
return array("Success" => "-1" , "Message" => "OverFlow in Ticket Title Variable! Type Of Variable Is String(500) " );
}elseif(mb_strlen($this->Body)>3000){
return array("Success" => "-1" , "Message" => "OverFlow in Ticket Body Variable! Type Of Variable Is String(3000) " );
}elseif(!is_numeric($this->BoardId) ){
return array("Success" => "-1" , "Message" => "BoardId Should Be Number!" );
}else{
$this->ticket_id = $this->obj_ticket->save(NULL, $this->Title, $this->Body, $this->UserIdSender , date("Y-m-d H:i:s"), "" , 3 , 0 , $this->BoardId);
$this->obj_ticket_owner->save(NULL, $this->ticket_id, $this->UserIdReciver, date("Y-m-d H:i:s"), 3, 0, 1);
if($this->obj_ticket->flage && $this->obj_ticket_owner->flage){
$this->obj_ticket->commit(TRUE);
$this->obj_ticket_owner->commit(TRUE);
$boardname = get_board_name($this->BoardId);
$robot_msg = "\xF0\x9F\x93\xA2 Your Ticket Has Been Successfuly Refrenced From Portal. \n\x23\xE2\x83\xA3 $this->ticket_id \n\xF0\x9F\x93\x8B Board $boardname";
send_with_telegram($this->UserIdReciver, $robot_msg,$this->UserIdSender);
return array("Success" => "1" , "Message" => "Your Ticket Has Been Successfuly Refrenced." );
}else{
$this->obj_ticket->commit(FALSE);
$this->obj_ticket_owner->commit(FALSE);
return array("Success" => "-1" , "Message" => "Error In Ticket Referrals!" );
}
}
}
public function SaveTicketFromPortalResponse($Token){
}
}
$params=array("uri"=>"http://127.0.0.1/board/my-webservice/portal/server.php");
$server = new SoapServer(NULL,$params);
$server->setClass("server");
$server->handle();
when i use address "server.php?wsdl" for call my Soap Function from asp.net i recive a error like this :
WSDL generation is no supported yet.!
please help.
its emergency.
thanks a lot.
i found it =>
wsdl.php
<?php
$functions = array();
$serviceName = "My Webservice For Recive Data From Portal";
$functions[] = array("funcName" => "SaveTicketFromPortal",
"doc" => "My Webservice For Recive Data From Portal",
"inputParams" => array(array("name" => "Token", "type" => "string"),
array("name" => "NationalCodeSender", "type" => "string"),
array("name" => "NationalCodeReciver", "type" => "string"),
array("name" => "Title", "type" => "string"),
array("name" => "Body", "type" => "string")
),
"outputParams" => array(array("name" => "Success", "type" => "string"),
array("name" => "Message" ,"type" => "string" )),
"soapAddress" => "http://192.168.10.16/board/my-webservice/portal/server.php"
);
$functions[] = array("funcName" => "SetState",
"doc" => "To Change Ticket State From Todo To Doing And Done",
"inputParams" => array(array("name" => "Token", "type" => "string"),
array("name" => "TicketId", "type" => "string"),
array("name" => "NationalCode", "type" => "string"),
array("name" => "StateId", "type" => "string")),
"outputParams" => array(array("name" => "Success", "type" => "string"),
array("name" => "Message" ,"type" => "string" )),
"soapAddress" => "http://192.168.10.16/board/my-webservice/portal/server.php"
);
if (stristr($_SERVER['QUERY_STRING'], "wsdl")) {
// WSDL request - output raw XML
header("Content-Type: application/soap+xml; charset=utf-8");
echo DisplayXML();
} else {
// Page accessed normally - output documentation
$cp = substr($_SERVER["SCRIPT_NAME"], strrpos($_SERVER["SCRIPT_NAME"], "/") + 1); // Current page
echo '<!-- Attention: To access via a SOAP client use ' . $cp . '?WSDL -->';
echo '<html>';
echo '<head><title>' . $serviceName . '</title></head>';
echo '<body>';
echo '<h1>' . $serviceName . '</h1>';
echo '<p style="margin-left:20px;">To access via a SOAP client use <code>' . $cp . '?WSDL</code></p>';
// Document each function
echo '<h2>Available Functions:</h2>';
echo '<div style="margin-left:20px;">';
for ($i=0;$i<count($functions);$i++) {
echo '<h3>Function: ' . $functions[$i]['funcName'] . '</h3>';
echo '<div style="margin-left:20px;">';
echo '<p>';
echo $functions[$i]['doc'];
echo '<ul>';
if (array_key_exists("inputParams", $functions[$i])) {
echo '<li>Input Parameters:<ul>';
for ($j=0;$j<count($functions[$i]['inputParams']);$j++) {
echo '<li>' . $functions[$i]['inputParams'][$j]['name'];
echo ' (' . $functions[$i]['inputParams'][$j]['type'];
echo ')</li>';
}
echo '</ul></li>';
}
if (array_key_exists("outputParams", $functions[$i])) {
echo '<li>Output Parameters:<ul>';
for ($j=0;$j<count($functions[$i]['outputParams']);$j++) {
echo '<li>' . $functions[$i]['outputParams'][$j]['name'];
echo ' (' . $functions[$i]['outputParams'][$j]['type'];
echo ')</li>';
}
echo '</ul></li>';
}
echo '</ul>';
echo '</p>';
echo '</div>';
}
echo '</div>';
echo '<h2>WSDL output:</h2>';
echo '<pre style="margin-left:20px;width:800px;overflow-x:scroll;border:1px solid black;padding:10px;background-color:#D3D3D3;">';
echo DisplayXML(false);
echo '</pre>';
echo '</body></html>';
}
exit;
/*****************************************************************************
* Create WSDL XML
* #PARAM xmlformat=true - Display output in HTML friendly format if set false
*****************************************************************************/
function DisplayXML($xmlformat=true) {
global $functions; // Functions that this web service supports
global $serviceName; // Web Service ID
$i = 0; // For traversing functions array
$j = 0; // For traversing parameters arrays
$str = ''; // XML String to output
// Tab spacings
$t1 = ' ';
if (!$xmlformat) $t1 = ' ';
$t2 = $t1 . $t1;
$t3 = $t2 . $t1;
$t4 = $t3 . $t1;
$t5 = $t4 . $t1;
$serviceID = str_replace(" ", "", $serviceName);
// Declare XML format
$str .= '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n\n";
// Declare definitions / namespaces
$str .= '<wsdl:definitions ' . "\n";
$str .= $t1 . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' . "\n";
$str .= $t1 . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' . "\n";
$str .= $t1 . 'xmlns:s="http://www.w3.org/2001/XMLSchema" ' . "\n";
$str .= $t1 . 'targetNamespace="http://www.darkerwhite.com/" ' . "\n";
$str .= $t1 . 'xmlns:tns="http://www.darkerwhite.com/" ' . "\n";
$str .= $t1 . 'name="' . $serviceID . '" ' . "\n";
$str .= '>' . "\n\n";
// Declare Types / Schema
$str .= '<wsdl:types>' . "\n";
$str .= $t1 . '<s:schema elementFormDefault="qualified" targetNamespace="http://www.darkerwhite.com/">' . "\n";
for ($i=0;$i<count($functions);$i++) {
// Define Request Types
if (array_key_exists("inputParams", $functions[$i])) {
$str .= $t2 . '<s:element name="' . $functions[$i]['funcName'] . 'Request">' . "\n";
$str .= $t3 . '<s:complexType><s:sequence>' . "\n";
for ($j=0;$j<count($functions[$i]['inputParams']);$j++) {
$str .= $t4 . '<s:element minOccurs="1" maxOccurs="1" ';
$str .= 'name="' . $functions[$i]['inputParams'][$j]['name'] . '" ';
$str .= 'type="s:' . $functions[$i]['inputParams'][$j]['type'] . '" />' . "\n";
}
$str .= $t3 . '</s:sequence></s:complexType>' . "\n";
$str .= $t2 . '</s:element>' . "\n";
}
// Define Response Types
if (array_key_exists("outputParams", $functions[$i])) {
$str .= $t2 . '<s:element name="' . $functions[$i]['funcName'] . 'Response">' . "\n";
$str .= $t3 . '<s:complexType><s:sequence>' . "\n";
for ($j=0;$j<count($functions[$i]['outputParams']);$j++) {
$str .= $t4 . '<s:element minOccurs="1" maxOccurs="1" ';
$str .= 'name="' . $functions[$i]['outputParams'][$j]['name'] . '" ';
$str .= 'type="s:' . $functions[$i]['outputParams'][$j]['type'] . '" />' . "\n";
}
$str .= $t3 . '</s:sequence></s:complexType>' . "\n";
$str .= $t2 . '</s:element>' . "\n";
}
}
$str .= $t1 . '</s:schema>' . "\n";
$str .= '</wsdl:types>' . "\n\n";
// Declare Messages
for ($i=0;$i<count($functions);$i++) {
// Define Request Messages
if (array_key_exists("inputParams", $functions[$i])) {
$str .= '<wsdl:message name="' . $functions[$i]['funcName'] . 'Request">' . "\n";
$str .= $t1 . '<wsdl:part name="parameters" element="tns:' . $functions[$i]['funcName'] . 'Request" />' . "\n";
$str .= '</wsdl:message>' . "\n";
}
// Define Response Messages
if (array_key_exists("outputParams", $functions[$i])) {
$str .= '<wsdl:message name="' . $functions[$i]['funcName'] . 'Response">' . "\n";
$str .= $t1 . '<wsdl:part name="parameters" element="tns:' . $functions[$i]['funcName'] . 'Response" />' . "\n";
$str .= '</wsdl:message>' . "\n\n";
}
}
// Declare Port Types
for ($i=0;$i<count($functions);$i++) {
$str .= '<wsdl:portType name="' . $functions[$i]['funcName'] . 'PortType">' . "\n";
$str .= $t1 . '<wsdl:operation name="' . $functions[$i]['funcName'] . '">' . "\n";
if (array_key_exists("inputParams", $functions[$i]))
$str .= $t2 . '<wsdl:input message="tns:' . $functions[$i]['funcName'] . 'Request" />' . "\n";
if (array_key_exists("outputParams", $functions[$i]))
$str .= $t2 . '<wsdl:output message="tns:' . $functions[$i]['funcName'] . 'Response" />' . "\n";
$str .= $t1 . '</wsdl:operation>' . "\n";
$str .= '</wsdl:portType>' . "\n\n";
}
// Declare Bindings
for ($i=0;$i<count($functions);$i++) {
$str .= '<wsdl:binding name="' . $functions[$i]['funcName'] . 'Binding" type="tns:' . $functions[$i]['funcName'] . 'PortType">' . "\n";
$str .= $t1 . '<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />' . "\n";
$str .= $t1 . '<wsdl:operation name="' . $functions[$i]['funcName'] . '">' . "\n";
$str .= $t2 . '<soap:operation soapAction="' . $functions[$i]['soapAddress'] . '#' . $functions[$i]['funcName'] . '" style="document" />' . "\n";
if (array_key_exists("inputParams", $functions[$i]))
$str .= $t2 . '<wsdl:input><soap:body use="literal" /></wsdl:input>' . "\n";
if (array_key_exists("outputParams", $functions[$i]))
$str .= $t2 . '<wsdl:output><soap:body use="literal" /></wsdl:output>' . "\n";
$str .= $t2 . '<wsdl:documentation>' . $functions[$i]['doc'] . '</wsdl:documentation>' . "\n";
$str .= $t1 . '</wsdl:operation>' . "\n";
$str .= '</wsdl:binding>' . "\n\n";
}
// Declare Service
$str .= '<wsdl:service name="' . $serviceID . '">' . "\n";
for ($i=0;$i<count($functions);$i++) {
$str .= $t1 . '<wsdl:port name="' . $functions[$i]['funcName'] . 'Port" binding="tns:' . $functions[$i]['funcName'] . 'Binding">' . "\n";
$str .= $t2 . '<soap:address location="' . $functions[$i]['soapAddress'] . '" />' . "\n";
$str .= $t1 . '</wsdl:port>' . "\n";
}
$str .= '</wsdl:service>' . "\n\n";
// End Document
$str .= '</wsdl:definitions>' . "\n";
if (!$xmlformat) $str = str_replace("<", "<", $str);
if (!$xmlformat) $str = str_replace(">", ">", $str);
if (!$xmlformat) $str = str_replace("\n", "<br />", $str);
return $str;
}
?>

Remove preceding whitespace within textarea tags in html content

For my Zend Framework library i have this view-helper that indents code.
I have added the solution in the code below
<?php
class My_View_Helper_Indent
{
function indent($indent, $string, $space = ' ')
{
if($string == '') {
return '';
}
$indent = str_repeat($space, $indent);
$content = $indent . str_replace("\n", "\n" . $indent, rtrim($string)) . PHP_EOL;
// BEGIN SOLUTION TO PROBLEM
// Based on user CodeAngry's answer
$callback = function($matches) use ($indent) {
$matches[2] = str_replace("\n" . $indent, "\n", $matches[2]);
return '<textarea' . $matches[1] . '>' . $matches[2] . '</textarea>';
};
$content = preg_replace_callback('~<textarea(.*?)>(.*?)</textarea>~si', $callback, $content);
// END
return $content;
}
}
And with the following test code..
$content = 'This is some text' . PHP_EOL;
$content .= '<div>' . PHP_EOL;
$content .= ' Text inside div, indented' . PHP_EOL;
$content .= '</div>' . PHP_EOL;
$content .= '<form>' . PHP_EOL;
$content .= ' <ul>' . PHP_EOL;
$content .= ' <li>' . PHP_EOL;
$content .= ' <label>inputfield</label>' . PHP_EOL;
$content .= ' <input type="text" />' . PHP_EOL;
$content .= ' </li>' . PHP_EOL;
$content .= ' <li>' . PHP_EOL;
$content .= ' <textarea cols="80" rows="10">' . PHP_EOL;
$content .= 'content of text area' . PHP_EOL;
$content .= ' this line is intentionally indented with 3 whitespaces' . PHP_EOL;
$content .= 'content of text area' . PHP_EOL;
$content .= ' </textarea>' . PHP_EOL;
$content .= ' </li>' . PHP_EOL;
$content .= ' </ul>' . PHP_EOL;
$content .= '</form>' . PHP_EOL;
$content .= 'The end';
echo $this->view->indent (6, $content);
What i would like to do, is to remove X whitespace characters from lines with the textarea tags. Where X matches the number of spaces that the code was indented, in the example above it's 6 spaces.
$html = preg_replace('~<textarea(.*?)>\s*(.*?)\s*</textarea>~si',
'<textarea$1>$2</textarea>', $html);
Try this regular expression. Should trim the contents of your textarea contents. Is this what you need?
OR:
$html = preg_replace_callback('~<textarea(.*?)>(.*?)</textarea>~si', function($matches){
$matches[2] = trim($matches[2]); // trim 2nd capture (inner textarea)
return "<textarea{$matches[1]}>{$matches[2]}</textarea>";
}, $html);

Using arrays in PHP

I am working on my first program written in PHP. This is a basic question. I am trying to print a string stored in an array. I have two arrays. One array, $content, stores a number at $content[$i][15] (i am using arrays in arrays, and looping through it with a for loop). Lets say this number is 3. I now want to access a string in another array, called $type. This string is at position $type[3]. Logically, I think, $type[3] should print the same thing as $type[$content[$i][15]]. But, when I call $type[$content[$i][15]], it doesn't print anything, but when i print $type[3] it works fine. Is this type of call not allowed in PHP?
$type = array();
$typetemp = readfile("type.csv");
foreach ($typetemp as $sa){
$type[$sa[0]] = $sa[1];
}
$content = readfile("content.csv");
for($i=0; $i<sizeof($content); $i++){
if($content[$i][15] == 3){
if($content[$i][4] == 1){
$temp = $content[$i][15];
echo "id is " . $content[$i][0] . "title is " . $content[$i][1] . "introtext is " . $content[$i][2] . "restoftext is " . $content[$i][3] . "visible is " . $content[$i][4] . "category is " . $content[$i][5] . "creation_date is " . $content[$i][6] . "author is " . $content[$i][7] . "img is " . $content[$i][8] . "ordering is " . $content[$i][9] . "rank is " . $content[$i][10] . "vid is " . $content[$i][11] . "start_date is " . $content[$i][12] . "stop_date is " . $content[$i][13] . "event_date is " . $content[$i][14] . "type is " . $content[$i][15] . "thumb is " . $content[$i][16] . "type name is " . $type[$temp] . "<br/>";
}
}
}
function readfile($filename) {
$line_of_text = array();
$file_handle = fopen($filename, "r");
while (!feof($file_handle) ) {
array_push($line_of_text, fgetcsv($file_handle, 1024));
}
fclose($file_handle);
return $line_of_text;
}
You are missing a $ sign before content:
$type[$content[$i][15]]
This accesses the value in $type with index $content[$i][15]

Incorrect string format

i need help in correcting this string.
I am trying:
$returnStr = 'Condition<select name="lstCondition" onchange="javascript:addDateTextbox(this.value,' . ' " ' . $colName . ' ", ' . $key . ')">';
I want this:
<select name="lstCondition" onchange="javascript:addDateTextbox(this.value, 'dateTime', 42)>
I am getting this:
<select name="lstCondition" onchange="javascript:addDateTextbox(this.value, " dateTime ", 42)>
In your statement
name="lstCondition" onchange="javascript:addDateTextbox(this.value,' . ' " ' . $colName . ' ", ' . $key . ')">';
you have spaces each side of the ' marks hence you're getting the spaces round the colname.
If you change it to
name="lstCondition" onchange="javascript:addDateTextbox(this.value,' . '\'' . $colName . '\', ' . $key . ')">';
you should get the result you wanted. I have escaped the '
$returnStr = 'Condition<select name="lstCondition"
onchange="javascript:addDateTextbox
(this.value,' . ' \'' . $colName . ' \',' . $key . ')">';
try the below code
<?php
$returnStr = '<select name="lstCondition" onchange="javascript:addDateTextbox(this.value, \'dateTime\', 42)"><option>Select</option></select>';
echo $returnStr;
?>

Convert anonymous function in PHP 5.3 into PHP 5.2 equivalent

I have error in line 2 and 13 in PHP 5.2, I have no idea to make the correction, I tried using create_function but not working, can anyone help with this?
function _process_special_keyword($str){
$callback = function($match){
$ret = $match[1] . '[' . $match[2] . ']';
if(!empty($match[3])){
$ret .= '.[' . $match[3] . ']';
}
$ret .= $match[4];
return $ret;
};
$strSQL = preg_replace_callback('/([\s\(\.,])(' . SPECIAL_KEYWORDS . ')(?:\.(' . SPECIAL_KEYWORDS . '))?([\s\)\.,])/i', $callback, $str);
$callback = function($match){
return 'CASE WHEN ' . $match[1] . ' THEN ' . $match[2] . ' ELSE ' . $match[3] . ' END';
};
$strSQL = preg_replace_callback('/if\s*\((.+),(.+),(.+)\)/i', $callback, $strSQL);
return $strSQL;
}
Thanks.
Error: Parse error: syntax error, unexpected T_FUNCTION
When using create_function(), the contents of the first argument should be a string representation of the PHP code that would fill the parentheses for the function declaration. The second argument should contain only the code inside the curly braces {} of the function declaration, the actual declaration itself should be omitted.
Try this code:
function _process_special_keyword($str){
$callback = create_function(
'$match',
'
$ret = $match[1] . "[" . $match[2] . "]";
if(!empty($match[3])){
$ret .= ".[" . $match[3] . "]";
}
$ret .= $match[4];
return $ret;
'
);
$strSQL = preg_replace_callback('/([\s\(\.,])(' . SPECIAL_KEYWORDS . ')(?:\.(' . SPECIAL_KEYWORDS . '))?([\s\)\.,])/i', $callback, $str);
$callback = create_function(
'$match',
'return "CASE WHEN " . $match[1] . " THEN " . $match[2] . " ELSE " . $match[3] . " END";'
);
$strSQL = preg_replace_callback('/if\s*\((.+),(.+),(.+)\)/i', $callback, $strSQL);
return $strSQL;
}
You can declare the callbacks outside of this function. Like this:
function _callback_one($match){
$ret = $match[1] . '[' . $match[2] . ']';
if(!empty($match[3])){
$ret .= '.[' . $match[3] . ']';
}
$ret .= $match[4];
return $ret;
}
function _callback_two($match){
return 'CASE WHEN ' . $match[1] . ' THEN ' . $match[2] . ' ELSE ' . $match[3] . ' END';
}
function _process_special_keyword($str){
$strSQL = preg_replace_callback('/([\s\(\.,])(' . SPECIAL_KEYWORDS . ')(?:\.(' . SPECIAL_KEYWORDS . '))?([\s\)\.,])/i', '_callback_one', $str);
$strSQL = preg_replace_callback('/if\s*\((.+),(.+),(.+)\)/i', '_callback_two', $strSQL);
return $strSQL;
}
Note: If these functions are in a class (meaning the function would be need to called like $this->_callback_one), pass an array as the "callback" parameter.
function _process_special_keyword($str){
$strSQL = preg_replace_callback('/([\s\(\.,])(' . SPECIAL_KEYWORDS . ')(?:\.(' . SPECIAL_KEYWORDS . '))?([\s\)\.,])/i', array($this, '_callback_one'), $str);
$strSQL = preg_replace_callback('/if\s*\((.+),(.+),(.+)\)/i', array($this, '_callback_two'), $strSQL);
return $strSQL;
}
according with object question, the faster way I think is something like so,
$f = <<<myfunc
\$ret = \$match[1] . '[' . \$match[2] . ']';
if(!empty(\$match[3])){
\$ret .= '.[' . \$match[3] . ']';
}
\$ret .= \$match[4];
return \$ret;
myfunc;
$callback = create_function('$match',$f);
note backslashes before $ and <<< FLAG FLAG; construct. In practice the answer of Rocket is more simple.

Categories