本文整理汇总了PHP中toString函数的典型用法代码示例。如果您正苦于以下问题:PHP toString函数的具体用法?PHP toString怎么用?PHP toString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toString
function toString($value)
{
version_assert and assertTrue(count(func_get_args()) == 1);
version_assert and assertTrue(count(debug_backtrace()) < 1024, "Infinite recursion detected");
if (is_object($value)) {
$value = _toCorrectClass($value);
}
if (is_object($value) && hasMember($value, 'toString')) {
return $value->toString();
} else {
if (is_object($value) && hasMember($value, 'toRaw')) {
return toString($value->toRaw());
} else {
if (is_array($value)) {
$intermediate = array();
foreach ($value as $v) {
$intermediate[] = toString($v);
}
return '[' . implode(', ', $intermediate) . ']';
} else {
return (string) $value;
}
}
}
}
示例2: run
public function run($method, $para = array(), $return = "", $charset = "utf-8")
{
$result = "";
if (isset($this->methods[$method])) {
$result = call_user_func_array($this->methods[$method], $para);
}
if (empty($charset)) {
$charset = "utf-8";
}
switch ($return) {
case "j":
case "json":
$result = toJson($result, $charset);
break;
case "x":
case "xml":
$result = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n<mystep>\n" . toXML($result) . "</mystep>";
header('Content-Type: application/xml; charset=' . $charset);
break;
case "s":
case "string":
$result = toString($result);
break;
default:
break;
}
return $result;
}
示例3: paginatedListAction
/**
* Returns the List of Calls paginated for Bootstrap Table depending of the current User
*
* @Route("/list", name="_admin_calls_list")
* @Security("is_granted('ROLE_EMPLOYEE')")
* @Template()
*/
public function paginatedListAction()
{
$request = $this->get('request');
if (!$this->get('request')->isXmlHttpRequest()) {
// Is the request an ajax one?
return new Response("<b>Not an ajax call!!!" . "</b>");
}
$logger = $this->get('logger');
try {
$limit = $request->get('limit');
$offset = $request->get('offset');
$order = $request->get('order');
$search = $request->get('search');
$sort = $request->get('sort');
$em = $this->getDoctrine()->getManager();
$usr = $this->get('security.context')->getToken()->getUser();
$isAdmin = $this->get('security.context')->isGranted('ROLE_ADMIN');
$paginator = $em->getRepository('Tech506CallServiceBundle:Call')->getPageWithFilterForUser($offset, $limit, $search, $sort, $order, $isAdmin, $usr);
$results = $this->getResults($paginator);
return new Response(json_encode(array('total' => count($paginator), 'rows' => $results)));
} catch (Exception $e) {
$info = toString($e);
$logger->err('User::getUsersList [' . $info . "]");
return new Response(json_encode(array('error' => true, 'message' => $info)));
}
}
示例4: GetBudgetSuggestionExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetBudgetSuggestionExample(AdWordsUser $user)
{
// Get the service, which loads the required classes.
$budgetSuggestionService = $user->GetService('BudgetSuggestionService', ADWORDS_VERSION);
$criteria = array();
// Create selector.
$selector = new BudgetSuggestionSelector();
// Criterion - Travel Agency product/service.
// See GetProductServicesExample.php for an example of how to get valid
// product/service settings.
$productService = new ProductService();
$productService->text = "Travel Agency";
$productService->locale = "en_US";
$criteria[] = $productService;
// Criterion - English language.
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
$language = new Language();
$language->id = 1000;
$criteria[] = $language;
// Criterion - Mountain View, California location.
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/geotargeting
// https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions
$location = new Location();
$location->id = 1014044;
$criteria[] = $location;
$selector->criteria = $criteria;
$budgetSuggestion = $budgetSuggestionService->get($selector);
printf("Budget suggestion for criteria is:\n" . " SuggestedBudget=%s\n" . " Min/MaxBudget=%s/%s\n" . " Min/MaxCpc=%s/%s\n" . " CPM=%s\n" . " CPC=%s\n" . " Impressions=%d\n", toString($budgetSuggestion->suggestedBudget), toString($budgetSuggestion->minBudget), toString($budgetSuggestion->maxBudget), toString($budgetSuggestion->minCpc), toString($budgetSuggestion->maxCpc), toString($budgetSuggestion->cpm), toString($budgetSuggestion->cpc), $budgetSuggestion->impressions);
}
示例5: __toString
function __toString($node, &$result)
{
switch ($node->nodeType) {
case XML_COMMENT_NODE:
$result .= '<!-- ' . $node->nodeValue . ' -->';
break;
case XML_TEXT_NODE:
$result .= '<p>' . $node->nodeValue . '</p>';
break;
case XML_CDATASection:
break;
default:
$result .= '<' . $node->nodeName;
if ($node->hasAttributes()) {
foreach ($node->attributes as $key => $val) {
$result .= ' ' . $key . '="' . $val . '"';
}
}
if ($node->hasChildNodes()) {
$result .= '>';
foreach ($node->childNodes as $child) {
toString($child, $result);
}
$result .= '</' . $node->nodeName . '>';
} else {
$result .= '/>';
}
}
}
示例6: afficher
function afficher()
{
if ($score = afficherBDD() and isset($score)) {
toString($score);
} else {
echo "erreur de la base";
}
}
示例7: gen_client_id
function gen_client_id()
{
$uuid = Uuid::uuid4();
$cid = $uuid . toString();
// Put it in a cookie to use in the future
setcookie('gacid', $cid, time() + 60 * 60 * 24 * 365 * 2, '/', '.prodatakey.com');
return $cid;
}
示例8: __toString
/**
* Return string representation (which will also be a valid CLI command) of this command.
*
* @return void
*/
public function __toString()
{
$str = $this->getName() . ' ';
foreach ($_options as $option) {
$str .= $_option . toString() . next($_options) ? ' ' : '';
}
foreach ($_resources as $resource) {
$str .= $_resource;
}
}
示例9: http_build_query
function http_build_query(&$data)
{
$keys = array_keys($data);
$string = '';
$f = true;
foreach ($keys as $key) {
if ($f) {
$string .= $key . '=' . toString($data[$key]);
$f = false;
} else {
$string .= '&' . $key . '=' . toString($data[$key]);
}
}
return $string;
}
示例10: sendHtmlAction
public function sendHtmlAction()
{
$sendTo = @$_POST['sendTo'] ?: '';
$from = @$_POST['from'] ?: '';
$url = @$_POST['url'] ?: '';
$content = @$_POST['content'] ?: '';
$imageEnabled = isset($_POST['imageEnabled']) && $_POST['imageEnabled'] === '1' ? true : false;
d($_POST);
try {
$this->result['result'] = Service::sendHtmlToKindle($sendTo, $from, $url, $content, $imageEnabled);
} catch (Exception $e) {
d($e);
$this->result['message'] = toString($e);
}
$this->render($this->result);
}
示例11: string
function string($n)
{
if (js()) {
if (typeof($n) === "number") {
return Number($n) . toString();
} else {
if (typeof($n) === "undefined") {
return "";
} else {
return $n . toString();
}
}
} else {
return "" . $n;
}
}
示例12: con
/**
* A convenience for throwing a PreconditionException.
*/
function con($assertation, $location, $msg, ...$variables)
{
if ($assertation === true) {
return;
}
$first = true;
$msg_var = "";
foreach ($variables as $var) {
if ($first) {
$msg_var .= toString($var);
} else {
$msg_var .= ", " . toString($var);
}
$first = false;
}
throw new Exception($location . " - " . $msg . $msg_var);
}
示例13: getAndCleanData
function getAndCleanData($dataWindPrev)
{
$url = $dataWindPrev->getUrl();
$step = 0;
$start_time = microtime(true);
// top chrono
try {
$result = $this->getDataURL($url);
$step = 1;
$result = $this->analyseData($result, $url);
$step = 2;
$result = $this->transformData($result);
$step = 3;
} catch (Exception $e) {
$result = toString($e);
}
$chrono = microtime(true) - $start_time;
return array($step, $result, $chrono);
}
示例14: replaceAll
/**
* Replaces all old string within the expression with new strings.
*
* @param String|\Tbm\Peval\Types\String $expression
* The string being processed.
* @param String|\Tbm\Peval\Types\String $oldString
* The string to replace.
* @param String|\Tbm\Peval\Types\String $newString
* The string to replace the old string with.
*
* @return mixed The new expression with all of the old strings replaced with new
* strings.
*/
public function replaceAll(string $expression, string $oldString, string $newString)
{
$replacedExpression = $expression;
if ($replacedExpression != null) {
$charCtr = 0;
$oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr);
while ($oldStringIndex > -1) {
// Remove the old string from the expression.
$buffer = new StringBuffer($replacedExpression->subString(0, oldStringIndex)->getValue() . $replacedExpression->substring($oldStringIndex + $oldString . length()));
// Insert the new string into the expression.
$buffer . insert($oldStringIndex, $newString);
$replacedExpression = buffer . toString();
$charCtr = $oldStringIndex + $newString->length();
// Determine if we need to continue to search.
if ($charCtr < $replacedExpression->length()) {
$oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr);
} else {
$oldStringIndex = -1;
}
}
}
return $replacedExpression;
}
示例15: __construct
/**
*
*/
function __construct($host, $username, $passwd, $dbname)
{
$this->con = @new mysqli($host, $username, $passwd, $dbname);
if ($this->con->connect_error) {
$msg = toString($this->con->connect_error);
//weird exception makes the message blank, if encoding errors occur.
throw new Exception(strip_to_ascii($msg));
}
$this->con->set_charset("utf8");
}