- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有谁知道为什么 Notepad++ 不支持 MySQLi 函数?另外,如果你想在使用 notepad++ 的同时使用 MySQLi 函数(如 mysqli_prepare()
),你必须做什么?
这是我要使用的代码:
<?php
function insert_batchmem_mysqli($file, $batchsize)
{
if(!$f = fopen($file, 'r'))
{
printf("Failed to open file: %s\n", $file);
exit;
}
$mysqli = new mysqli('localhost', 'dbuser', 'dbpass', 'database');
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$template = "INSERT INTO words (word) VALUES %batch";
$numrows = 0;
$batchrows = 1;
$batch = "";
while($line = fgets($f))
{
if($batchrows < $batchsize)
{
$batch .= "('{$line}'),";
++$batchrows;
}
elseif($batchrows == $batchsize)
{
$batch .= "('{$line}')";
$query = str_replace("%batch", $batch, $template);
$mysqli->query($query);
$batch = "";
$batchrows = 1;
}
++$numrows;
}
if(!empty($batch)) // Last batch was not executed because it was smaller than batchsize
{
$batch = substr($batch, 0, strlen($batch)-1); // Remove trailing comma
$query = str_replace("%batch", $batch, $template);
$mysqli->query($query);
}
$mysqli->close();
fclose($f);
return $numrows;
}
?>
subst
功能会起作用。事实上,它们甚至不会像 Notepad++ 中的方法一样以粗体蓝色字体出现。
最佳答案
关于PHP的语法着色...
扩展 Notepad++ 可识别的 PHP 关键字
当使用 mysqli 'procedural' 编码风格时,以下适用,不幸的是我仍然没有成功使用 'object' 编码风格。
第一次检查时,Notepad++ 似乎在语法突出显示中缺少一些关键字,尤其是一些较新的 mysqli_*
函数,奇怪的是一些更通用的函数,例如 array_keys
, fclose
, is_dir
等等。据我了解,这并不是 Notepad++ 的错,它依赖于其他项目来编译预期的语言关键字,幸运的是,Notepad++ 为最终用户提供了通过“设置”>“样式配置器”>“语言:PHP”来扩充这些列表的工具> 样式:WORD > 用户定义的关键字'。
“样式配置器”还列出了 Notepad++ 已经知道的“默认关键字”,其中包含许多重复项。我怀疑mysqli_*
函数已添加了它们的 ' i
' 被错误地删除,因为许多 mysql_*
有 3 个重复项功能,甚至一些mysql_*
列出的函数只应实际存在于 mysqli_*
形式。
我想:“这应该很简单,我只需获得一个明确的 php 关键字列表并将它们粘贴到 Notepad++ 配置中,就完成了”......但事实证明 PHP 只有几个 (67) 内置关键字,以及在添加模块时成为 PHP 安装一部分的更多内容。
根据http://www.php.net/manual/en/reserved.keywords.php PHP 中保留了以下 67 种语言结构:__halt_compiler abstract and array as break callable case catch class clone const continue declare default die do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit extends final finally for foreach function global goto if implements include include_once instanceof insteadof interface isset list namespace new or print private protected public require require_once return static switch throw trait try unset use var while xor yield
为简单起见,我很高兴不是 为了区分“语言结构”和“模块函数”,所以我不会在第一次尝试中使 Notepad++ 语法突出显示的配置复杂化,我只想要一个相当全面的模块函数列表,这些函数存在于我当前的 PHP 安装中,即可以粘贴到 Notepad++ 配置中。
这可以通过使用'get_defined_functions()
相当快地实现。 ' PHP 中的函数。 (我不知道哪个基本模块提供了这个有用的功能,但它从 PHP 版本 4.0.4+ 开始可用)它返回一个带有 2 个子数组的关联数组,一个包含我们正在搜索的“内部”函数,另一个包含碰巧在当前脚本上下文中创建的“用户”函数,我现在将忽略它。
以下脚本将列出应为您的特定 PHP 安装添加到 Notepad++ 中的所有关键字。如果您已经在 Notepad++ 中有一个“用户定义的关键字”列表,您可以将它们添加到 $usr_kw_str
如脚本中所示,定义由空格分隔,这会将它们从结果中排除,并仅显示那些当前未被 Notepad++ 识别的关键字。 (或者您可以将此字符串留空,并用生成的完整列表替换任何现有的用户定义关键字。)
<?php
# Default Keywords - List any existing 'Default Keywords' here separated by spaces
$def_kw_str = 'filesize filemtime ksort sort count shell_exec disk_free_space disk_total_space file_exists strip_tags htmlentities stripslashes mysql_real_escape_string session_start error_reporting define srt_replace pathinfo date time version_compare sha1 sha1_file md5 md5_file ignore_user_abort and or xor __dir__ __method__ __namespace__ __file__ __line__ array as break case cfunction class const continue declare default die do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit extends for foreach function global if include include_once isset list new old_function print require require_once return static switch unset use var while __function__ __class__ php_version php_os default_include_path pear_install_dir pear_extension_dir php_extension_dir php_bindir php_libdir php_datadir php_sysconfdir php_localstatedir php_config_file_path php_output_handler_start php_output_handler_cont php_output_handler_end e_error e_warning e_parse e_notice e_core_error e_core_warning e_compile_error e_compile_warning e_user_error e_user_warning e_user_notice e_all true false bool boolean int integer float double real string array object resource null class extends parent stdclass directory __sleep __wakeup interface implements abstract public protected private printf print_r php_major_version php_minor_version php_release_version php_version_id php_extra_version php_zts php_debug php_maxpathlen php_sapi php_eol php_int_max php_int_size php_prefix php_mandir php_config_file_scan_dir php_shlib_suffix php_windows_version_major php_windows_version_minor php_windows_version_build php_windows_version_platform php_windows_version_sp_major php_windows_version_sp_minor php_windows_version_suitemask php_windows_version_producttype php_windows_nt_domain_controller php_windows_nt_server php_windows_nt_workstation e_deprecated e_user_deprecated e_strict __compiler_halt_offset__ extr_overwrite extr_skip extr_prefix_same extr_prefix_all extr_prefix_invalid extr_prefix_if_exists extr_if_exists sort_asc sort_desc sort_regular sort_numeric sort_string case_lower case_upper count_normal count_recursive assert_active assert_callback assert_bail assert_warning assert_quiet_eval connection_aborted connection_normal connection_timeout ini_user ini_perdir ini_system ini_all m_e m_log2e m_log10e m_ln2 m_ln10 m_pi m_pi_2 m_pi_4 m_1_pi m_2_pi m_2_sqrtpi m_sqrt2 m_sqrt1_2 crypt_salt_length crypt_std_des crypt_ext_des crypt_md5 crypt_blowfish directory_separator seek_set seek_cur seek_end lock_sh lock_ex lock_un lock_nb html_specialchars html_entities ent_compat ent_quotes ent_noquotes info_general info_credits info_configuration info_modules info_environment info_variables info_license info_all credits_group credits_general credits_sapi credits_modules credits_docs credits_fullpage credits_qa credits_all str_pad_left str_pad_right str_pad_both pathinfo_dirname pathinfo_basename pathinfo_extension path_separator char_max lc_ctype lc_numeric lc_time lc_collate lc_monetary lc_all lc_messages abday_1 abday_2 abday_3 abday_4 abday_5 abday_6 abday_7 day_1 day_2 day_3 day_4 day_5 day_6 day_7 abmon_1 abmon_2 abmon_3 abmon_4 abmon_5 abmon_6 abmon_7 abmon_8 abmon_9 abmon_10 abmon_11 abmon_12 mon_1 mon_2 mon_3 mon_4 mon_5 mon_6 mon_7 mon_8 mon_9 mon_10 mon_11 mon_12 am_str pm_str d_t_fmt d_fmt t_fmt t_fmt_ampm era era_year era_d_t_fmt era_d_fmt era_t_fmt alt_digits int_curr_symbol currency_symbol crncystr mon_decimal_point mon_thousands_sep mon_grouping positive_sign negative_sign int_frac_digits frac_digits p_cs_precedes p_sep_by_space n_cs_precedes n_sep_by_space p_sign_posn n_sign_posn decimal_point radixchar thousands_sep thousep grouping yesexpr noexpr yesstr nostr codeset log_emerg log_alert log_crit log_err log_warning log_notice log_info log_debug log_kern log_user log_mail log_daemon log_auth log_syslog log_lpr log_news log_uucp log_cron log_authpriv log_local0 log_local1 log_local2 log_local3 log_local4 log_local5 log_local6 log_local7 log_pid log_cons log_odelay log_ndelay log_nowait log_perror msql_connect msql_close msql msql_create_db msql_createdb msql_drop_db msql_drop_db msql_select_db msql_select_db msql_pconnect msql msql_create_db msql_createdb msql_drop_db msql_drop_db msql_select_db msql_select_db msql_db_query msql_list_dbs msql_list_fields msql_list_tables msql_query msql msql_affected_rows msql_data_seek msql_dbname msql_fetch_array msql_fetch_field msql_fetch_object msql_fetch_row msql_field_seek msql_field_table msql_field_flags msql_field_len msql_field_name msql_field_type msql_num_fields msql_num_rows msql_numfields msql_numrows msql_result mssql_connect mssql_query mssql_select_db mssql_close mssql_pconnect mssql_query mssql_select_db mssql_query mssql_data_seek mssql_fetch_array mssql_fetch_field mssql_fetch_object mssql_fetch_row mssql_field_length mssql_field_name mssql_field_seek mssql_field_type mssql_num_fields mssql_num_rows mssql_result mssql_free_result mysql_connect mysql_affected_rows mysql_change_user mysql_create_db mysql_data_seek mysql_db_name mysql_db_query mysql_drop_db mysql_errno mysql_error mysql_insert_id mysql_list_dbs mysql_list_fields mysql_list_tables mysql_query mysql_result mysql_select_db mysql_tablename mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_close mysql_pconnect mysql_affected_rows mysql_change_user mysql_create_db mysql_data_seek mysql_db_name mysql_db_query mysql_drop_db mysql_errno mysql_error mysql_insert_id mysql_list_dbs mysql_list_fields mysql_list_tables mysql_query mysql_result mysql_select_db mysql_tablename mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_db_query mysql_list_dbs mysql_list_fields mysql_list_processes mysql_list_tables mysql_query mysql_unbuffered_query mysql_data_seek mysql_db_name mysql_fetch_array mysql_fetch_assoc mysql_fetch_field mysql_fetch_lengths mysql_fetch_object mysql_fetch_row mysql_fetch_row mysql_field_flags mysql_field_name mysql_field_len mysql_field_seek mysql_field_table mysql_field_type mysql_num_fields mysql_num_rows mysql_result mysql_tablename mysql_free_result ocilogon ociplogon ocinlogon ocicommit ociserverversion ocinewcursor ociparse ocierror ocilogoff ocinewdescriptor ocirollback ocinewdescriptor ocirowcount ocidefinebyname ocibindbyname ociexecute ocinumcols ociresult ocifetch ocifetchinto ocifetchstatement ocicolumnisnull ocicolumnname ocicolumnsize ocicolumntype ocistatementtype ocierror ocifreestatement odbc_connect odbc_autocommit odbc_commit odbc_error odbc_errormsg odbc_exec odbc_tables odbc_tableprivileges odbc_do odbc_prepare odbc_columns odbc_columnprivileges odbc_procedurecolumns odbc_specialcolumns odbc_rollback odbc_setoption odbc_gettypeinfo odbc_primarykeys odbc_foreignkeys odbc_procedures odbc_statistics odbc_close odbc_pconnect odbc_autocommit odbc_commit odbc_error odbc_errormsg odbc_exec odbc_tables odbc_tableprivileges odbc_do odbc_prepare odbc_columns odbc_columnprivileges odbc_procedurecolumns odbc_specialcolumns odbc_rollback odbc_setoption odbc_gettypeinfo odbc_primarykeys odbc_foreignkeys odbc_procedures odbc_statistics odbc_prepare odbc_binmode odbc_cursor odbc_execute odbc_fetch_into odbc_fetch_row odbc_field_name odbc_field_num odbc_field_type odbc_field_len odbc_field_precision odbc_field_scale odbc_longreadlen odbc_num_fields odbc_num_rows odbc_result odbc_result_all odbc_setoption odbc_free_result openssl_get_privatekey openssl_get_publickey openssl_sign openssl_seal openssl_open openssl_verify openssl_free_key xml_parser_create xml_parser_create_ns xml_set_object xml_set_element_handler xml_set_character_data_handler xml_set_processing_instruction_handler xml_set_default_handler xml_set_unparsed_entity_decl_handler xml_set_notation_decl_handler xml_set_external_entity_ref_handler xml_parse xml_get_error_code xml_error_string xml_get_current_line_number xml_get_current_column_number xml_get_current_byte_index xml_parse_into_struct xml_parser_set_option xml_parser_get_option xml_parser_free gzopen gzeof gzgetc gzgets gzgetss gzpassthru gzputs gzread gzrewind gzseek gztell gzwrite gzclose bzopen bzerrno bzerror bzerrstr bzflush bzread bzwrite bzclose com_load com_invoke com_propget com_get com_propput com_set com_propput imagecreate imagecreatefromgd imagecreatefromgd2 imagecreatefromgd2part imagecreatefromgif imagecreatefromjpeg imagecreatefrompng imagecreatefromwbmp imagecreatefromstring imagecreatefromxbm imagecreatefromxpm imagecreatetruecolor imagerotate imagearc imagechar imagecharup imagecolorallocate imagecolorat imagecolorclosest imagecolorexact imagecolorresolve imagegammacorrect imagegammacorrect imagecolorset imagecolorsforindex imagecolorstotal imagecolortransparent imagecopy imagecopyresized imagedashedline imagefill imagefilledpolygon imagefilledrectangle imagefilltoborder imagegif imagepng imagejpeg imagewbmp imageinterlace imageline imagepolygon imagepstext imagerectangle imagerotate imagesetpixel imagestring imagestringup imagesx imagesy imagettftext imagefilledarc imageellipse imagefilledellipse imagecolorclosestalpha imagecolorexactalpha imagecolorresolvealpha imagecopymerge imagecopymergegray imagecopyresampled imagetruecolortopalette imagesetbrush imagesettile imagesetthickness image2wbmp imagealphablending imageantialias imagecolorallocatealpha imagecolorclosesthwb imagecolordeallocate imagecolormatch imagefilter imagefttext imagegd imagegd2 imageistruecolor imagelayereffect imagepalettecopy imagesavealpha imagesetstyle imagexbm imagedestroy imageloadfont imagechar imagecharup imagefontheight imagepsloadfont imagepstext imagepsslantfont imagepsextendfont imagepsencodefont imagepsbbox imagepsfreefont curl_copy_handle curl_init curl_copy_handle curl_errno curl_error curl_exec curl_getinfo curl_setopt curl_close dba_open dba_delete dba_exists dba_fetch dba_firstkey dba_insert dba_nextkey dba_optimize dba_replace dba_sync dba_close dba_popen dba_delete dba_exists dba_fetch dba_firstkey dba_insert dba_nextkey dba_optimize dba_replace dba_sync strstr strtoupper strtolower strpos explode implode closedir getdir floatval rtrim fwrite extension_loaded final catch clone goto instanceof namespace throw try trigger_error ftp_connect ftp_ssl_connect ftp_close ftp_login ftp_pwd ftp_cdup ftp_chdir ftp_mkdir ftp_rmdir ftp_nlist ftp_rawlist ftp_systype ftp_pasv ftp_get ftp_fget ftp_put ftp_fput ftp_size ftp_mdtm ftp_rename ftp_delete ftp_site ftp_alloc ftp_chmod ftp_exec ftp_get_option ftp_nb_continue ftp_nb_fget ftp_nb_fput ftp_nb_get ftp_nb_put ftp_raw ftp_set_option imap_open imap_close imap_append imap_body imap_check imap_createmailbox imap_delete imap_deletemailbox imap_expunge imap_fetchbody imap_fetchstructure imap_headerinfo imap_header imap_headers imap_listmailbox imap_getmailboxes imap_get_quota imap_status imap_listsubscribed imap_set_quota imap_set_quota imap_getsubscribed imap_mail_copy imap_mail_move imap_num_msg imap_num_recent imap_ping imap_renamemailbox imap_reopen imap_subscribe imap_undelete imap_unsubscribe imap_scanmailbox imap_mailboxmsginfo imap_fetchheader imap_uid imap_msgno imap_search imap_fetch_overview array_change_key_case array_chunk array_combine array_count_values array_diff array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill array_fill_keys array_filter array_flip array_intersect array_intersect_assoc array_intersect_key array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map array_merge array_merge_recursive array_multisort array_pad array_pop array_product array_push array_rand array_reduce array_replace array_replace_recursive array_reverse array_search array_shift array_slice array_splice array_sum array_udiff array_udiff_assoc array_udiff_uassoc array_uintersect array_uintersect_assoc array_uintersect_uassoc array_unique array_unshift array_values array_walk array_walk_recursive arrayaccess arrayiterator arrayobject flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf fseek fsockopen fstat ftell __construct __destruct'; # <- List any existing 'Default Keywords' here separated by spaces
$def_kw_arr = explode(' ',$def_kw_str);
sort($def_kw_arr);
# User Defined Keywords - List any existing 'User-defined Keywords' here separated by spaces
$usr_kw_str = ''; # <- List any existing 'User-defined Keywords' here separated by spaces
$usr_kw_arr = explode(' ',$usr_kw_str);
sort($usr_kw_arr);
# Internal Keywords
$fn_arr = get_defined_functions();
$int_kw_arr = $fn_arr['internal'];
# New Keywords
$new_kw_arr = array();
foreach($def_kw_arr as $kw){ @$all_kw_arr["$kw"]++; }
foreach($usr_kw_arr as $kw){ @$all_kw_arr["$kw"]++; }
foreach($int_kw_arr as $kw){ if(!isset($all_kw_arr["$kw"])){ $new_kw_arr["$kw"] = "$kw"; } }
sort($new_kw_arr);
$new_kw_str = join(' ',$new_kw_arr);
echo"$new_kw_str\n";
?>
关于php - 在 Notepad++ 中使用 MySQLi 函数需要包括哪些内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17572020/
我需要删除某个字符后的所有内容。 例如以下行: email:pass | text | text | text | text 我如何删除"pass"之后的所有内容,使其最终像这样: email:pas
我看到一旦我打开一个新文件并在其中写入一些内容,即使我不保存它,当我再次打开 notepad++ 时,该文件也会打开。那么如何在notepad++中保存工作区的状态,即使我不保存呢?任何人都可以指出它
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 7年前关闭。 Improve this qu
这个问题听起来可能很愚蠢。 我正在使用 NP++ 6.8.8(我添加主页的最新版本) 我想使用函数列表(基本上如 here 所述), 没什么特别的,只是为了看看 PHP 函数。 我可以打开功能列表窗口
我有一个包含数字和字符的文本文件(阿拉伯语) 像这样: 943894رنيش964737 ترشقة1045051 ضمنزلبالق10653 对此: 943894964737 1045051 10
我有一些命令行工具,有时需要在外部编辑器中调出文件才能进行编辑。这些工具依赖于编辑器的阻止行为:退出编辑器程序后,他们希望文件已被修改和保存。 但是,这不是Notepad++起作用的方式。从命令行启动
我正在努力弄清楚如何在 Notepad++ 中替换日期格式 我有一个包含不同日期的 key 。 2014/01/03 应改为: 2014-01-03 等等。 关于如何做到这一点的任何建议? 最佳答案
有没有办法为 Notepad++ 创建自定义命名区域来折叠它们? 我看过一些关于它的讨论,但没有找到如何操作的功能示例。 最佳答案 我用: //{ NAME OF REGION/BLOCK //} 关
我想知道是否有可能在Notepad++的“查找文件”功能中列出文件过滤器中的排除项。 例如,以下内容将在所有文件中用Dog替换Dog。 查找内容:狗 替换为:猫 过滤器:*。* 我想做的是在.sh文件
我在我的 Windows 机器上使用 Notepad++,我错误地打开了一个 64MB 的文件。现在我的 Notepad++ 被永久卡住了,我无法使用它。 Notepad++ 是否有任何配置文件来维护
这个问题可能有点跑题,但我无法从其他任何地方获得帮助。 早期的 Notepad++ 在菜单中有Stream Comment 和Toggle Block Comment 选项,但现在找不到了。无论如何要
是否有某种 CSS tidy 可用于 Notepad++。我已经尝试过似乎是 TEXTFX 中的每个菜单项,但似乎都没有。我习惯于使用 PSPAD,您只需选择 CSS 并单击“重新格式化为结构化 CS
嗨,我正在编辑要在我的数据库中使用的 csv 文件。从几个星期开始,当我用 Notepad++ 打开它时,我发现最后有一个坏字符,它像 CR 一样破坏了我的文件。 IE "30-APR-2014","
当我每天在工作中使用Notepad ++时,我想对其进行扩展以提高工作效率。 我想做的是选择包含单词的多行,右键单击并单击一个菜单项,例如“逗号分隔”,然后将所有单词放在一行中以逗号分隔。 我知道No
我有一个 C++ 源文件,它使用 getMemberName() 形式的函数返回成员数据。相反,我想使用 memberName()。 为了匹配需要更改的函数名称实例,我使用了以下正则表达式: (\s+
我导出了一个显示服务器备份状态的备份报告,服务器有一个父作业和子作业。报告状态仅与父作业相关的行相关,子作业提供无关信息。父作业包含关键字“每周”。如何显示报告以仅显示带有 Weekly 一词的行,应
我知道如何使用“运行->运行”或F5自动运行命令。我也知道如何使用快捷方式保存命令。我的问题是,考虑到我已经保存了一条快捷方式的命令,并且该命令现在出现在“运行”菜单中,并且我忘记了要输入的内容作为运
Notepad++是否可以导航到定义?我想给它一个我的库所在的目录,搜索它并在新选项卡的引用行中打开源/头文件。很像NetBeans。 我刚刚安装了SourceCookifier,这很好,但是除了已经
情况: 在 n++ 中打开一个文本文件,进行一些修改,按 ALT-F4 或关闭程序。N++ 不会询问“是否要保存更改”。相反,它会退出并且硬盘上的文本文件保持不变。 但是当我再次打开 N++ 时,MO
我喜欢 Notepad++ 。它做了我需要它做的一切。我不需要一个花哨的 IDE,我从命令行使用 makefile 进行编译,而且我从事的项目并不是非常大,它们只是变得越来越小。这张图片很好地描述了我
我是一名优秀的程序员,十分优秀!