This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
It's about a different way of passing params to an sql query. Yes, still using PDO behind the scenes. | |
*/ | |
/////////////////////////// | |
//The standard way of passing params: | |
$stmt = $dbh->prepare("INSERT INTO some_table (first_name, last_name) VALUES (?, ?)"); | |
$stmt->bindValue(1, $_GET['first_name']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Here is an example of type hinting variables (not function parameters), using php doc. | |
There is only one reason for doing this - to let IDEs know what is what. | |
*/ | |
class X{ | |
public function blahx(){ | |
echo 'blahx'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disclaimer - I am aware using __call to set things isn't anything new, once upon a time, I created an ORM class doing that, but this | |
* time I'd like to ask about using this approach actually everytime we need accessors like set/get. | |
* | |
* OK, so using accessors is a good practice. But quite boring, isn't it? Even with all this IDEs' support (menu code -> create accessors for me please). | |
* | |
* Why not use the __call magic method catching "get/set" methods? | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create two files: | |
PHP file get_image.php: | |
<?php | |
//you'll play with dirs / paths later | |
$file = 'some_image.png'; | |
$type = 'image/png'; | |
header('Content-Type:'.$type); | |
header('Content-Length: ' . filesize($file)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adfadfadsf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to get PHP errors to log/display | |
TL;DR: | |
Put/modify this in the php.ini file: | |
error_reporting = -1 | |
display_errors = On | |
Long version: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bind ^S savefile main | |
bind ^F whereis main | |
bind F3 findnext main | |
#bind esc cancel main | |
bind ^X cut main | |
bind ^C copytext main | |
bind ^V uncut main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df -h /dev/sdc1 | |
Filesystem Size Used Avail Use% Mounted on | |
/dev/sdc1 699G 692G 6,8G 100% /media/konrad/Elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function defaultMethod() { | |
lib::$view->assign("pageTemplate", $this->templateDir."cities.tpl"); | |
$cityId = 2; | |
$defaultCityIds = '2, 3, 7, 12'; | |
$cityIds = null; | |
if (isset($_GET['city']) && !empty($_GET['city'])) { | |
$cityId = $_GET['city']; | |
$cityIds = $_GET['city']; | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when you installed the Tree Style Tab in your Firefox Quantum or any newer, | |
# you don't need the FX's Tab Bar anymore, therefore: | |
1. Click help -> Troubleshooting Information -> next to "Profile Directory " click "Open Directory". | |
(if you can't see the menu, click the "wrench" icon on the right, then Help and Troubleshooting Information ) | |
2. Create (if not exists) a "chrome" directory | |
3. Create (if not exists) "userChrome.css" file and edit it |
OlderNewer