本文整理汇总了PHP中toString函数的典型用法代码示例。如果您正苦于以下问题:PHP toString函数的具体用法?PHP toString怎么用?PHP toString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
}
开发者ID:luka8088,项目名称:phops,代码行数:25,代码来源:overload.php
示例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;
}
开发者ID:laiello,项目名称:mystep-cms,代码行数:28,代码来源:myapi.class.php
示例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)));
}
}
开发者ID:selimcr,项目名称:servigases,代码行数:33,代码来源:CallsController.php
示例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);
}
开发者ID:googleads,项目名称:googleads-php-lib,代码行数:35,代码来源:GetBudgetSuggestion.php
示例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 .= '/>';
}
}
}
开发者ID:GruppoMeta,项目名称:Movio,代码行数:29,代码来源:ForceNoTagText.php
示例6: afficher
function afficher()
{
if ($score = afficherBDD() and isset($score)) {
toString($score);
} else {
echo "erreur de la base";
}
}
开发者ID:Bleuh,项目名称:Couple,代码行数:8,代码来源:score.php
示例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;
}
开发者ID:prodatakey,项目名称:yourls-gatrack,代码行数:8,代码来源:plugin.php
示例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;
}
}
开发者ID:jon9872,项目名称:zend-framework,代码行数:15,代码来源:Abstract.php
示例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;
}
开发者ID:subashemphasize,项目名称:test_site,代码行数:15,代码来源:bp20.php
示例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);
}
开发者ID:gammodoking,项目名称:kindle.server,代码行数:16,代码来源:ApiController.php
示例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;
}
}
开发者ID:tantek,项目名称:cassis,代码行数:16,代码来源:cassis.php
示例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);
}
开发者ID:wistoft,项目名称:BST,代码行数:20,代码来源:wBasic.php
示例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);
}
开发者ID:lapoiz,项目名称:WindServer2,代码行数:19,代码来源:WebsiteGetData.php
示例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;
}
开发者ID:ghooning,项目名称:peval,代码行数:36,代码来源:EvaluationHelper.php
示例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");
}
开发者ID:wistoft,项目名称:BST,代码行数:13,代码来源:gybala.php
示例16: dayString
function dayString($jd, $next, $flag)
{
//only ever calls 0,2 or 0,3
// returns a string in the form DDMMMYYYY[ next] to display prev/next rise/set
// flag=2 for DD MMM, 3 for DD MM YYYY, 4 for DDMMYYYY next/prev
if ($jd < 900000 || $jd > 2817000) {
$output = "error";
} else {
$z = floor($jd + 0.5);
$f = $jd + 0.5 - $z;
if ($z < 2299161) {
$A = $z;
} else {
$alpha = floor(($z - 1867216.25) / 36524.25);
$A = $z + 1 + $alpha - floor($alpha / 4);
}
$B = $A + 1524;
$C = floor(($B - 122.1) / 365.25);
$D = floor(365.25 * $C);
$E = floor(($B - $D) / 30.6001);
$day = $B - $D - floor(30.6001 * $E) + $f;
$month = $E < 14 ? $E - 1 : $E - 13;
$year = $month > 2 ? $C - 4716 : $C - 4715;
if ($flag == 2) {
$output = $this->zeroPad($day, 2) . " " . $this->monthList($month);
}
if ($flag == 3) {
$output = $this->zeroPad($day, 2) . $this->monthList($month) . year . toString();
}
if ($flag == 4) {
$output = $this->zeroPad($day, 2) . $this->monthList($month) . year . toString() . ($next ? " next" : " prev");
}
}
return $output;
}
开发者ID:techtronics,项目名称:theblackboxproject,代码行数:35,代码来源:lib-solcalc.php
示例17: saveServiceRowsAction
/**
* @Route("/details/save", name="_admin_services_rows_save")
* @Security("is_granted('ROLE_ADMIN')")
* @Template()
*/
public function saveServiceRowsAction()
{
$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 {
$em = $this->getDoctrine()->getManager();
$serviceId = $request->get('serviceId');
$technicianService = $em->getRepository('Tech506CallServiceBundle:TechnicianService')->find($serviceId);
$oldDetails = $technicianService->getDetails();
$data = $request->get('data');
/*
0: detail.id
1: detail.productSaleType.product.id
2: detail.productSaleType.id
3: detail.fullPrice
4: detail.sellerWin
5: detail.technicianWin
6: detail.transportationCost
7: detail.utility
8: detail.observations
*/
$rows = explode("<>", $data);
$updatedRows = array();
foreach ($rows as $row) {
if ($row != "") {
$rowData = explode("/", $row);
/*$logger->info("--------------------------------------------");
$logger->info("row: " . $row);
$logger->info("detail id: " . $rowData[0]);
$logger->info("product id: " . $rowData[1]);
$logger->info("produc sale type id: " . $rowData[2]);
$logger->info("full price: " . $rowData[3]);
$logger->info("seller: " . $rowData[4]);
$logger->info("technician: " . $rowData[5]);
$logger->info("transportation: " . $rowData[6]);
$logger->info("utility: " . $rowData[7]);
$logger->info("observations: " . $rowData[8]);*/
$serviceDetail = new ServiceDetail();
if ($rowData[0] != 0) {
//Must update the Row
array_push($updatedRows, $rowData[0]);
$serviceDetail = $em->getRepository('Tech506CallServiceBundle:ServiceDetail')->find($rowData[0]);
} else {
$serviceDetail->setTechnicianService($technicianService);
$saleType = $em->getRepository('Tech506CallServiceBundle:ProductSaleType')->find($rowData[2]);
$serviceDetail->setProductSaleType($saleType);
}
$serviceDetail->setFullPrice($rowData[3]);
$serviceDetail->setSellerWin($rowData[4]);
$serviceDetail->setTechnicianWin($rowData[5]);
$serviceDetail->setTransportationCost($rowData[6]);
$serviceDetail->setUtility($rowData[7]);
$serviceDetail->setObservations($rowData[8]);
$em->persist($serviceDetail);
//$serviceDetail->setQuantity();
}
}
$detailsToRemove = array();
foreach ($oldDetails as $detail) {
if (!in_array($detail->getId(), $updatedRows)) {
array_push($detailsToRemove, $detail);
$em->remove($detail);
}
}
foreach ($detailsToRemove as $detail) {
$technicianService->removeDetail($detail);
}
$em->persist($technicianService);
$em->flush();
$translator = $this->get('translator');
return new Response(json_encode(array('error' => false, 'msg' => $translator->trans('information.save.success'))));
} catch (Exception $e) {
$info = toString($e);
$logger->err('Services::saveServiceRowsAction [' . $info . "]");
return new Response(json_encode(array('error' => true, 'message' => $info)));
}
}
开发者ID:selimcr,项目名称:servigases,代码行数:86,代码来源:ServicesController.php
示例18: debug
function debug($var)
{
$traces = debug_backtrace();
$places = array();
foreach ($traces as $trace) {
$places[] = str_replace(array(DIR_ROOT, '\\'), array('', '/'), $trace['file'] . ':' . $trace['line']);
}
$place = str_replace(':', ', line ', array_shift($places));
$trace = debug_backtrace();
$trace = array_shift($trace);
$place = str_replace(array(DIR_ROOT, '\\'), array('', '/'), $trace['file'] . ', line ' . $trace['line']);
$vars = array();
foreach (func_get_args() as $var) {
$vars[] = nl2br(toString($var));
}
$places = join(" ", $places);
print system_window("<u>DEBUG</u> at <span title=\"{$places}\">{$place}</span>", $vars, '#CDE');
return true;
}
开发者ID:laiello,项目名称:php-garden,代码行数:19,代码来源:pretty-print-variable.php
示例19: xml_parser_create
function &xmlFileToArray($fileName, $includeTopTag = false, $lowerCaseTags = true)
{
// Definition file not found
if (!file_exists($fileName)) {
// Error
$false = false;
return $false;
}
$p = xml_parser_create();
xml_parse_into_struct($p, toString($fileName), $vals, $index);
xml_parser_free($p);
$xml = array();
$levels = array();
$multipleData = array();
$prevTag = "";
$currTag = "";
$topTag = false;
foreach ($vals as $val) {
// Open tag
if ($val["type"] == "open") {
if (!_xmlFileToArrayOpen($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml)) {
continue;
}
} else {
if ($val["type"] == "close") {
if (!_xmlFileToArrayClose($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml)) {
continue;
}
} else {
if ($val["type"] == "complete" && isset($val["value"])) {
$loc =& $xml;
foreach ($levels as $level) {
$temp =& $loc[str_replace(":arr#", "", $level)];
$loc =& $temp;
}
$tag = $val["tag"];
if ($lowerCaseTags) {
$tag = strtolower($val["tag"]);
}
$loc[$tag] = str_replace("\\n", "\n", $val["value"]);
} else {
if ($val["type"] == "complete") {
_xmlFileToArrayOpen($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml);
_xmlFileToArrayClose($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml);
}
}
}
}
}
return $xml;
}
开发者ID:hbustun,项目名称:agilebill,代码行数:51,代码来源:xml.inc.php
示例20: saveAssociationAction
/**
* Save or Update an Association
*
* @Route("/patients/association/save", name="_patients_save_association")
* @Security("is_granted('ROLE_EMPLOYEE')")
* @Template()
*/
public function saveAssociationAction()
{
$logger = $this->get('logger');
if ($this->get('request')->isXmlHttpRequest()) {
try {
//Get parameters
$request = $this->get('request');
$id = $request->get('id');
$association = $request->get('association');
$translator = $this->get("translator");
if (isset($id) && isset($association)) {
$em = $this->getDoctrine()->getManager();
$patient = $em->getRepository("TecnotekAsiloBundle:Patient")->find($id);
if (isset($patient)) {
switch ($association) {
case "pention":
$associationId = $request->get('associationId');
if (isset($associationId)) {
$action = $request->get("action");
switch ($action) {
case "save":
$patientPention = new PatientPention();
if ($associationId != 0) {
$patientPention = $em->getRepository("TecnotekAsiloBundle:PatientPention")->find($associationId);
}
$patientPention->setPatient($patient);
$pentionId = $request->get("pentionId");
$pention = $em->getRepository("TecnotekAsiloBundle:Pention")->find($pentionId);
if (isset($pention)) {
$patientPention->setPention($pention);
$detail = $request->get("name");
$detail = trim($detail) == "" ? $pention->getName() : $detail;
$patientPention->setDetail($detail);
$patientPention->setAmount($request->get("amount"));
$em->persist($patientPention);
$em->flush();
return new Response(json_encode(array('id' => $patientPention->getId(), 'name' => $detail, 'amount' => $patientPention->getAmount(), 'error' => false, 'msg' => $translator->trans('add.pention.success'))));
} else {
return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters Pention")));
}
break;
case "delete":
$patientPention = $em->getRepository("TecnotekAsiloBundle:PatientPention")->find($associationId);
$em->remove($patientPention);
$em->flush();
return new Response(json_encode(array('error' => false, 'msg' => "")));
break;
default:
return new Response(json_encode(array('error' => true, 'msg' => "Accion desconocida")));
}
} else {
return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters")));
}
break;
default:
break;
}
} else {
return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters Patient")));
}
} else {
return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters Id or Association")));
}
} catch (Exception $e) {
$info = toString($e);
$logger->err('Sport::saveSportAction [' . $info . "]");
return new Response(json_encode(array('error' => true, 'msg' => $info)));
}
} else {
return new Response("<b>Not an ajax call!!!" . "</b>");
}
}
开发者ID:selimcr,项目名称:servigases,代码行数:79,代码来源:PatientsController.php
注:本文中的toString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论