prosoxi.com | Archive | PHP

Plupload

The developers of TinyMCE brings you Plupload, a highly usable upload handler for your Content Management Systems or similar. Plupload is currently separated into a Core API and a jQuery upload queue widget this enables you to either use it out of the box or write your own custom implementation.

Continue Reading

Posted in Flash, HTML - XHTML, JavaScript - Ajax, PHP, Programming0 Comments

Composer

Dependency Manager for PHP.

Continue Reading

Posted in PHP0 Comments

Packagist

Packagist is the main Composer repository. It aggregates all sorts of PHP packages that are installable with Composer.

Continue Reading

Posted in PHP0 Comments

php fast-cgi No input file specified error

No input file specified error

Sometimes you may get this error when you switch the web server API module to CGI/FastCGI. I got this error during the site migration time.

Continue Reading

Posted in Linux, PHP0 Comments

NuSOAP

Introduction to NuSOAP

NuSOAP is a group of PHP classes that allow developers to create and consume SOAP web services. It does not require any special PHP extensions. The current release version (0.6.7) of NuSOAP at the time this was written (03-November-2004), supports much of the SOAP 1.1 specification. It can generate WSDL 1.1 and also consume it for use in serialization. Both rpc/encoded and document/literal services are supported. However, it must be noted that NuSOAP does not provide coverage of the SOAP 1.1 and WSDL 1.1 that is as complete as some other implementations, such as .NET and Apache Axis.

Continue Reading

Posted in PHP0 Comments

PHP json_encode vs serialize performance

If performance is you absolute driving characteristic, then by all means use the fastest one. Just make sure you have a full understanding of the differences before you make a choice

Continue Reading

Posted in PHP0 Comments

Blocking scraping website content

The + Symbol is nothing in specific, its just a query string appending variables.. (that url with + symbol is also accessible through curl anywayz.) If you are using an Apache server you can put the following in a .htaccess file to block out site stealers:

Continue Reading

Posted in Linux, PHP, Programming0 Comments

xajax

xajax is easy! Just include xajax, register
a function (or an object or class method)…

Continue Reading

Posted in JavaScript - Ajax, PHP0 Comments

Bcompiler GUI

About : Bcompiler GUI is a FREEWARE application that helps you compile and obfuscate your PHP scripts.
Encode and obfuscate PHP scripts using this software is simple and does not take any knowledge at all.
Bcompiler GUI encodes and obfuscates your PHP code to make the output difficult to reverse engineer, using bcompiler as compiler.

Continue Reading

Posted in PHP1 Comment

Bambalam PHP EXE Compiler/Embedder


Bambalam PHP EXE Compiler/Embedder

Continue Reading

Posted in PHP0 Comments

PHP phar

Today we will continue PHP lessons. I guess you noticed that due your project become larger – the more and more files it contain. Sometimes it comes to the thousands of files. And then – Phar can help you. This utility allows us to pack a variety of files in the single library file. Thus, we can significantly reduce the number of include files in the project, and work with the entire library as with single file. It is also possible to have a packed (gzip/bzip2) version of the library. These principles already using in other languages, such as a DLL library for system languages (as example .Net: N# and VB.Net) or JAR files for Java. Read more.

Continue Reading

Posted in PHP0 Comments

Packaging Your Apps with Phar

Deployment of web applications can be difficult and cumbersome if you don’t have the right tools. If you’ve ever deployed a Java application before, I’m sure you’ve heard of JAR files (which stands for “Java ARchive”). Everything executable/accessible that makes up the application can be bundled in a single JAR file, which is a blessing when it comes time to deploy.

Continue Reading

Posted in PHP0 Comments

PHP: disable PHP Timeout

By default, php scripts will timeout after 30 seconds. While not recommended, you can override this setting with the set_time_limit() command. Useful if you are using php to process multiple files, etc.

Continue Reading

Posted in PHP0 Comments

PHP reverse reading a text file

how can i read for example 10 last lines from a text file beginning
from last line

Continue Reading

Posted in PHP0 Comments

Read a file’s contents with PHP

PHP provides three built-in functions which allow you to easily read the contents of a file on your webserver. This is useful when, for example, another program may write information to the file and you could access that information through your script.

In this example, we’re going to use the following example 5 line file, saved as file.txt:

line 1
line 2
line 3
line 4
line 5

In the same directory as file.txt, we’re going to work with the PHP file test.php. We’ll outline the file reading functions below.

readfile()

readfile() is the least useful of the file functions. As a parameter, it takes a string which specifies the location of the file to read – this can be relative or absolute; since our file is the same directory as the script, we just need to pass the string ‘file.txt’ as this paramter. We call the function using the code readfile('file.txt') and it prints out the contents of the file straight to the browser:

// readfile() writes the contents of the file straight to the browser

echo 'Contents of file.txt using readfile():<br>';

readfile('file.txt');

The disadvantage of readfile() is that it doesn’t allow you to manipulate the file contents before displaying it – the next two functions we’re going to look at will allow you to do that.

file()

The code file('file.txt') will read the contents of file.txt into an array, which you can then manipulate in your scripts and display yourself. Each line of the file is stored in a seperate element of the array, this means that we can access and manipulate each line of the file seperately using normal array notation.

// file() loads the contents of file.txt into an array, $lines

// each line in the file becomes a seperate element of the array.

$lines = file('file.txt');

// now loop through the array to print the contents of the file

echo 'Contents of file.txt using file():<br>';

foreach ($lines as $line)

{

echo htmlspecialchars($line) . '<br>';

}

// we can also access each line of the file seperately

echo '3rd line of the file: "' . htmlspecialchars($lines[2]) . '"<br>';

In this example, we’ve loaded the contents of file.txt into an array called $lines then used foreach to loop through the array and display each line on the user’s browser. We then use $lines[2] to access the third line of the file (the element at array index 2, since line 1 is $lines[0]).

You may notice that we’ve used a function called htmlspecialchars() when displaying the file’s contents – this enables that special characters used in HTML, such as > and " are displayed correctly. This illustrates the power of file() over readfile() since readfile() was unable to perform this kind of processing.

get_file_contents()

The last method we will look at is get_file_contents(‘file.txt’) which is similar to file() however rather than returning an array, it returns a string with all the lines of the file. We can manipulate and display this in a similar way as with file():

// file_get_contents() reads the file and places the contents in a string

$fileString = file_get_contents('file.txt');

echo 'Contents of file.txt using file_get_contents():<br>';

echo nl2br( htmlspecialchars($fileString) );

Since we have no way of seperating the lines with this method, we’ve used the nl2br() function which converts line breaks in the string (represented by the special character n) into the HTML line break <br /> so that the file will display correctly on the visitor’s browser.

The full contents of test.php is below:

<?php

// file() loads the contents of file.txt into an array, $lines

// each line in the file becomes a seperate element of the array.

$lines = file('file.txt');

// now loop through the array to print the contents of the file

echo 'Contents of file.txt using file():

';

foreach ($lines as $line)

{

echo htmlspecialchars($line) . '<br>';

}

// we can also access each line of the file seperately

echo '3rd line of the file: "' . htmlspecialchars($lines[2]) . '"<br>';

echo '<br>';

// file_get_contents() reads the file and places the contents in a string

$fileString = file_get_contents('file.txt');

echo 'Contents of file.txt using file_get_contents():

';

echo nl2br( htmlspecialchars($fileString) );

echo '<br>';

// readfile() writes the contents of the file straight to the browser

echo 'Contents of file.txt using readfile():<br>';

readfile('file.txt');

?>

http://www.tiposaurus.co.uk/2011/04/05/reading-a-files-contents-with-php/

The output from test.php is:

Contents of file.txt using file():
line 1
line 2
line 3
line 4
line 5
3rd line of the file: "line 3 "

Contents of file.txt using file_get_contents():
line 1
line 2
line 3
line 4
line 5

Contents of file.txt using readfile():
line 1 line 2 line 3 line 4 line 5

Posted in PHP0 Comments

Spin Text For SEO – A PHP Spinner

I recently had an SEO expert give us a few hours of his time to provide some suggestions to compliment our SEO strategy. One of the techniques that he introduced I was so impressed with (due to it’s utter simplicity) that I am kicking myself for not thinking of it before! Basically, if you have ‘doorway’ pages into your site (e.g. you have pages for ‘Cambridge Widgets’ and ‘Preston Widgets’ and alike) and want them to be dynamically generated, from the same content, but not to suffer horrible duplicate content penalties, you can use a ‘spinning’ function to generate contextually similar, different, content. The original concept is here, but I have enhanced it a bit to better suit my needs.

Continue Reading

Posted in PHP0 Comments

Advertise

Whocallsme.gr Widget Lookup