$data) { $value->{$key} = stripslashes_deep( $data ); } } else { $value = stripslashes($value); } return $value; } /* MyPHP::stripslashes_deep () */ static function url ($url, $params = array()) { $sep = '?'; if (strpos($url, '?') !== false) : $sep = '&'; endif; $url .= $sep . self::to_http_post($params); return $url; } /* MyPHP::url () */ /** * MyPHP::to_http_post () -- convert a hash table or object into * an application/x-www-form-urlencoded query string */ static function to_http_post ($params) { $getQuery = array(); foreach ($params as $key => $value) : if (is_scalar($value)) : $getQuery[] = urlencode($key) . '=' . urlencode($value); else : // Make some attempt to deal with array and // object members. Really we should descend // recursively to get the whole thing.... foreach ((array) $value as $k => $v) : $getQuery[] = urlencode($key.'['.$k.']') . '=' . urlencode($v); endforeach; endif; endforeach; return implode("&", $getQuery); } /* MyPHP::to_http_post () */ /** * MyPHP::val(): Captures the output of var_dump() to a string, * with some optional filtering removing newlines and replacing * them with spaces) applied. * * @param mixed $v Value to dump to a string representation * @param bool $no_newlines Whether to filter out newline chars * * @return string */ static function val ($v, $no_newlines = false) { ob_start(); var_dump($v); $out = ob_get_contents(); ob_end_clean(); if ($no_newlines) : $out = preg_replace('/\s+/', " ", $out); endif; return $out; } /* MyPHP::val () */ } /* class MyPHP */ endif;