In last post we introduced how to install mongodb and the php extension on windows.
Lets do some CRUD operation in PHP script.
Install PEAR is very easy, just download http://pear.php.net/go-pear.phar and run
Then you can install mongodb like this:
A very common situation in web development is the category tree, in its nature , its just a recursive traversal of a tree data structure. This post will demonstrate the method of generating a tree while traversing the data strucute.
Step 1. Create a database table to store the category data:
A typical file name in windows is like "file.txt". How to get the extension name with php script?
If you think its too many lines:
PHP has built in networking api to access all kinds of services. Here is a script you can type in a command line window to upload a folder and all its sub directories to a FTP server. Sometimes it will be very handy with a command to do this kind of job.
Its very useful to record the site visitor information like ip address, search keywords, visit url...
Today I will write a simple php script to achieve that. First we need a database table to store the information. Here is the table:
How to zoom image in php? Here is a quick recipe.
<?php list($image_width, $image_height) = @getimagesize('xx.jpg'); $imgsrc = imagecreatefromjpeg('xx.jpg'); $towidth = 565; $newwidth = $towidth ; $newheight = ($image_height * $towidth )/$image_width; $imgdst = imagecreatetruecolor($newwidth , $newheight ); $copy = @imagecopyresized($imgdst, $imgsrc, 0, 0, 0,0, $newwidth , $newheight , $image_width, $image_height ); imagejpeg($imgdst, 'yy.jpg'); imagedestroy($imgsrc); imagedestroy($imgdst); ?>
How people usually open a file? First they have to locate it then double click it to launch the associated program or type file name in the terminal as parameter to the command.
What if the file you are handling reside in a very deep and complex directory tree.The file name can be very long. For example, the source code tree of large project. Below is part of jdk source code tree:What if the file you are handling reside in a very deep and complex directory tree.The file name can be very long. For example, the source .
The login information can store in session or cookie. When store in session, the default expire time is when browser is closed.
Change the default by set the session.cookie_lifetime option in php.ini.