Home >php教程 >php手册 >php动态绑定变量的用法

php动态绑定变量的用法

WBOY
WBOYOriginal
2016-06-06 20:03:191142browse

这篇文章主要介绍了php动态绑定变量的用法,涉及php变量的判定与动态定义的相关技巧,需要的朋友可以参考下

本文实例讲述了php动态绑定变量的用法。分享给大家供大家参考。具体如下:

private function bindVars($stmt,$params) { if ($params != null) { $types = ''; //initial sting with types foreach($params as $param) { //for each element, determine type and add if(is_int($param)) { $types .= 'i'; //integer } elseif (is_float($param)) { $types .= 'd'; //double } elseif (is_string($param)) { $types .= 's'; //string } else { $types .= 'b'; //blob and unknown } } $bind_names[] = $types; //first param needed is the type string // eg: 'issss' for ($i=0; $i

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn