akintunde102 / chocolate-php
此项目旨在帮助 PHP 程序员通过提供常见且至关重要的 PHP 操作的现成函数,使编程变得更加容易。
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-20 07:46:09 UTC
README
名称: CHOCOLATE-PHP
贡献者: Akintunde Jegede
类型: 库
编程语言: PHP
最低版本要求: php 5.*
主要依赖: PHP
许可证: Apache 许可证 2.0
许可证 URI: https://apache.ac.cn/licenses/LICENSE-2.0
Composer 安装: composer require akintunde102/chocolate dev-master
简短摘要
此项目旨在通过提供常见且至关重要的 PHP 操作的现成函数,帮助 PHP 程序员轻松编码。
描述
该库旨在成为重要 PHP 函数的首选库。它是一个持续的项目,将始终欢迎更多函数以满足 PHP 开发者可能需要的所有“功能”需求。目前,它有 2 个类和约 15 个重要 PHP 函数。
进一步描述
这些脚本有两个主要类
Chocolate 类
此类包含执行各种重要操作的通用函数。它包含以下列出的大多数函数:
shorten_words($string, $wordsreturned)
$string 表示要缩短的字符串
#wordsreturned 表示要缩短到多少个单词
if_word_present($string,$word)
$string 表示要检查的字符串
$word 表示要检查的单词
shorten_by_paragraph($string, $return)
$string 表示要按段落缩短的字符串
$return 表示要返回的段落数量
text_to_url($in,$mth)
$in 是要格式化为 URL 格式的 URL 或文本,例如 i love you 变为 i-love-you,您可以将此附加到自己的 URL 上
$mth 可以是 'up' 和 'down','up' 表示单词到 URL,'down' 表示从 URL 到单词
ossl_encrypt($string) , ossl_decrypt($string)
这些函数帮助您使用自己的密钥对字符串进行加密和解密。它要求您安装 openssl php 扩展 **,$string 表示要加密或解密的字符串
m_encrypt($string) ,m_decrypt($string)
这些函数帮助您使用自己的密钥对字符串进行加密和解密。它不需要您安装 openssl php 扩展 **,$string 表示要加密或解密的字符串
InitiateDownload($file,$ext)
这是直接下载,$file 是要下载的文件的名称(包括完整路径)(例如 'image/popup.jpg'),$ext 是文件扩展名,例如 'jpg'。
checkPHP()
此用于导入 PHPInfo(),它在一个可点击的文件中显示所有服务器详细信息,该文件自动生成为 php.html。
checkDomain($domain)
此连接到多个域名注册机构,并返回指定域的详细信息,这些详细信息在一个自动生成的可点击文件中,包含完整的 WHOIS 详细信息。
dirSize($dir)
这给出了指定为 $dir 的整个文件夹/目录的大小。它返回以下函数使用的可读文件大小格式。
human_filesize($bytes)
此函数返回文件大小的可读格式,因为直接进行除法操作时,结果可能很混乱。此函数负责处理这一点。
IsIPValid($ip)
此函数用于检查IP地址是否有效
synthaxPHP($code)
此函数简单地突出显示PHP代码。$code表示作为字符串传递的代码
以下是一个示例代码,说明如何初始化和使用作为类的chocolate
$a = new akintunde102\chocolatephp\chocolate;
$string = 'All versions of PHP that support namespaces support three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, and aliasing a namespace name. PHP 5.6+ also allows aliasing or importing function and constant names.';
$wordsreturned = 20;
$a->shorten_words($string, $wordsreturned); //Function example, You can use other functions in the class in the same way
快递类
此类主要用于执行邮件操作。以下是一些示例代码,指导如何初始化和使用快递类
$courier = new akintunde102\chocolatephp\courier;
$courier->sender = 'Example.Com <no-reply@example.com>'; //sender's email
$courier->recipient = $to; //recipient's email
$courier->subject = $title; //email title
$courier->message_text = $courier_txt; //the text format of the email
$courier->message_html = $sentence['full_html']; //the html format of the email
if ($courier->send($courier)){echo 'Email sent';}; //then it gets sent
安装
您可以使用composer简单安装此库。
如果您不了解composer,请在此处了解相关信息 这里
composer require akintunde102/chocolate-php dev-master
示例
<?php require_once 'vendor/autoload.php'; //Initiating and Using the Chocolate Class $a = new akintunde102\chocolatephp\chocolate; $string = 'All versions of PHP that support namespaces support three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, and aliasing a namespace name. PHP 5.6+ also allows aliasing or importing function and constant names.'; $wordsreturned = 20; $sh = $a->shorten_words($string, $wordsreturned); echo $sh; //Initiating and Using the Courier Class $courier = new akintunde102\chocolatephp\courier; $courier->sender = 'Example.Com <no-reply@example.com>'; //sender's email $courier->recipient = $to; //recipient's email $courier->subject = $title; //email title $courier->message_text = $courier_txt; //the text format of the email $courier->message_html = $sentence['full_html']; //the html format of the email if ($courier->send($courier)){echo 'Email sent';}; //then it gets sent ?>
测试
在使用前测试库,请按照以下步骤操作
-
转到vendor\akintunde102\chocolate-php\example并复制index.php
-
将index.php粘贴到主目录
-
然后您可以根据自己的喜好通过浏览器或命令行测试代码
OR
-
在主目录中创建一个文件,命名为(例如,'test.html')
-
然后将以下代码复制到文件中
<?php require_once 'vendor/autoload.php'; $a = new akintunde102\chocolatephp\chocolate; $string = 'All versions of PHP that support namespaces support three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, and aliasing a namespace name. PHP 5.6+ also allows aliasing or importing function and constant names.'; $wordsreturned = 20; $a->shorten_words($string, $wordsreturned); echo $a->checkPHP('errorfile'); echo '<br/><br/>'; echo $a->checkDomain('timiweb.com'); echo $a->dirSize('vendor/'); if ($a->IsIPValid('10.199.212.2')){echo 'IP is valid';} else {echo 'IP is invalid';} //Initiating and Using the Courier Class $courier = new akintunde102\chocolatephp\courier; $courier->sender = 'Example.Com <no-reply@example.com>'; //sender's email $courier->recipient = $to; //recipient's email $courier->subject = $title; //email title $courier->message_text = $courier_txt; //the text format of the email $courier->message_html = $sentence['full_html']; //the html format of the email if ($courier->send($courier)){echo 'Email sent';}; //then it gets sent ?>
当前版本
1.1
联系我
Discord: @akintunde
邮箱: jegedeakintunde[at]gmail.com
utopian.io: @akintunde
github: @akintunde102