php

Composer Require 'package' throws OpenSSL error

拥有回忆 提交于 2021-02-18 12:48:45
问题 This problem seems to be common, and i've been through a lot of SO posts related to it and nothing works, and i'm going crazy. Whats weird is that it was working perfectly few weeks ago, and i didnt install anything new since months... Setup : PHP 7.1.9 WAMPSERVER 3.1.0 APACHE 2.4.27 Composer 1.6.5 (latest) I'm not behind a proxy & no firewall Windows 10 What Works : composer self-update What does not work : Installing a package I cannot reach https://packagist.org/ with firefox 61.0.1

Mysql字符串截取函数

…衆ロ難τιáo~ 提交于 2021-02-18 12:32:22
有时候我们需要直接用MySQL的字符串函数截取字符,毕竟用程序截取(如PHP)还得先写个脚本连接数据库之类的,所以在这里做一个记录,希望对大家有用。 1、从左开始截取字符串 left(str, length) 说明:left(被截取字段,截取长度) 例: select left (content, 200 ) as abstract from my_content_t 2、从右开始截取字符串 right(str, length) 说明:right(被截取字段,截取长度) 例: select right (content, 200 ) as abstract from my_content_t 3、截取字符串 substring(str, pos) substring(str, pos, length) 说明:substring(被截取字段,从第几位开始截取) substring(被截取字段,从第几位开始截取,截取长度) 例: select substring (content, 5 ) as abstract from my_content_t select substring (content, 5 , 200 ) as abstract from my_content_t (注:如果位数是负数 如-5 则是从后倒数位数,到字符串结束或截取的长度) 4、按关键字截取字符串

PHP if file exists

时光怂恿深爱的人放手 提交于 2021-02-18 12:29:06
问题 Here is my code. $filename = "$myMedia catalog/category/ $myImage.png"; $filename = str_replace(" ", "", $filename); if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } The variable above outputs http://50.87.6.244/~storeupp/media/catalog/category/Game_Used.png which does exist. However, it says that it does not exists. Any idea why? 回答1: Just try to use like this: $filename = dirname(__FILE__) . "/ $myMedia catalog/category/

Odd and Even numbers (using & or %)

╄→гoц情女王★ 提交于 2021-02-18 12:14:06
问题 I've always used the following in order to find even and odd numbers: if( $num % 2 ) { echo "odd"; } if( !($num % 2) ) { echo "even"; } But recently I stumbled upon with the following code that works exactly the same: if( $num & 1 ) { echo "odd"; } if( !($num & 1) ) { echo "even; } What's the logic behind the "&" in the second method? I went to check the PHP: Arithmetic Operators and the ampersand is not part of the options. Thanks. 回答1: It is the bitwise-AND operator. Remember that in the

Failed to authenticate password using codeigniter

与世无争的帅哥 提交于 2021-02-18 12:10:24
问题 Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 wv1sm5867206pab.37 - gsmtp function index() { $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gauravkwt@gmail.com', 'smtp_pass' => '92135108845129', 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $this

Failed to authenticate password using codeigniter

久未见 提交于 2021-02-18 12:10:12
问题 Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 wv1sm5867206pab.37 - gsmtp function index() { $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gauravkwt@gmail.com', 'smtp_pass' => '92135108845129', 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $this

Failed to authenticate password using codeigniter

你离开我真会死。 提交于 2021-02-18 12:09:56
问题 Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 wv1sm5867206pab.37 - gsmtp function index() { $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gauravkwt@gmail.com', 'smtp_pass' => '92135108845129', 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $this

Laravel 4 Eloquent returns wrong ID

有些话、适合烂在心里 提交于 2021-02-18 12:04:27
问题 I have 3 tables in my database: Campaigns Users Companies One company may have some users. One user may have some campaigns. A user (with admin rights) can do some actions with any campaign that belongs to his company. So, I want to check whether he's doing these actions with his campaign or not (in the last case I return something like "access denied"). My condition Campaign::join('users', 'users.id', '=', 'campaigns.user_id') ->where('users.company_id', '=', Auth::user()->company->id) -

Laravel 4 Eloquent returns wrong ID

为君一笑 提交于 2021-02-18 12:03:45
问题 I have 3 tables in my database: Campaigns Users Companies One company may have some users. One user may have some campaigns. A user (with admin rights) can do some actions with any campaign that belongs to his company. So, I want to check whether he's doing these actions with his campaign or not (in the last case I return something like "access denied"). My condition Campaign::join('users', 'users.id', '=', 'campaigns.user_id') ->where('users.company_id', '=', Auth::user()->company->id) -

How do you use COUNT(*) with find('list') in CakePHP 3?

前提是你 提交于 2021-02-18 11:58:51
问题 In CakePHP 3, I had a model called Articles and a field called 'subject', and I ran into a roadblock trying to retrieve a list of the 100 most commonly-used article subjects. The following code's resulting SQL selected all of the possible fields and not COUNT(*) : $articles->find('list', [ 'keyField' => 'subject', 'valueField' => 'COUNT(*)' ]) ->group('subject') ->order(['COUNT(*)' => 'DESC']) ->limit(100) ->toArray(); Then I remembered "CakePHP’s ORM offers abstraction for some commonly used