14 Aug, 2010
Substr file_get_contents php
Articles related to substr file_get_contents php
http://digitalpbk.com/php/file_get_contents-garbled-gzip-encoding-website-scraping
PHP file_get_contents giving garbled output
Are you getting garbled values when using
file_get_contents fetching an external URL (website scrapping using
php) and wondering what went wrong ? The content is appearing to have wierd characters instead of normal HTML output because of GZIP output encoding by the website you are fetching.
You can fix this issue in multiple ways.
Method 1 : Accept-Encoding
In this method we set the request headers so that the webserver is forced to respond ...
Published 2 years, 2 months ago
http://digitalpbk.blogspot.com/2007/04/using-php-for-more-than-html.html
imagesheader("Content-Type: image/jpeg");echo
file_get_contents("../images/some.jpg");?>The above code returns a jpeg. But this is static everytime we see the some.jpg. The advantage of using
php to return image is that you can provide a authentication validation, i.e, the user must have signed in to view the image. Thus automatically hot linking is prevented. (Hot linking is the use of images of other servers, by another server. for eg an image on www.example.com displyed on www ...
Published 5 years, 1 month ago
http://digitalpbk.com/javascript/free-light-small-social-media-sharing-javascript-facebook-twitter-stumble-upon-digg-and-r
page load slow as well as bring in unintentional 3rd party javascript code ( or flash tracker ) which runs on your blog.
So it is always safe to use your own script or scripts which you can read understand and verify it just does what it is suppose to do. :)
Javascript Object for Social Media Sharing
var share = {
fb:function(title,url) {
this.share('http://www.facebook.com/sharer.php?u=##URL##&t=##TITLE##',title,url);
},
tw ...
Published 2 years, 2 months ago
http://digitalpbk.blogspot.com/2009/05/curl-php-windows-unable-load-libcurlphp.html
cURL
PHP Error on Windows
Fatal error: Call to undefined function curl_init() in D:/webs/
php.php on line 284This problem arises because of not including the lib_curl.dll to
PHP. To solve this uncomment the line as shown below;extension=
php_bz2.dllextension=
php_curl.dll;extension=php_dba.dllNow restart apache server. If you get an error "Unable to Load
X:/path/php/ext/php_curl.dll", copy SSLEAY32.PHPlibEAY32.dll (OpenSSL) Libraries to the System32 folder.Now restart apache server ...
Published 3 years ago
http://digitalpbk.com/virus/gumblar-web-virus-manual-removal-free-tool
Gumblar Virus Javascript removal using PERL
Gumblar virus infects all .html and .
php files and injects a piece of javascript in the source code. The code is usually found just below the <body> tag. The Javascript code Gumblar injects varies widely and usually attaches a script or inline frame inside your page to execute itself on page load. Read on to get rid of this virus.
Gumblar Source Code Samples when delimited by new lines
Sample 1
var D;
if(D!='' ...
Published 2 years, 1 month ago
http://digitalpbk.com/perl/script-fetch-pnr-status-reservation-train-indian-railways
the code below.
Requires: WWW::Mechanize module and PERL.
Usage: ./pnr.pl <PNR NUMBER>
EDIT: The Railways have changed their interface, so the script also have changed.
New Script
#!/usr/bin/perl
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$pnr = $ARGV[0];
$mech->get("http://www.indianrail.gov.in/pnr_Enq.html");
$part1 =
substr($pnr,0,3);
$part2 =
substr($pnr,3);
print " Fetching for PNR $part1-$part2 \n\n";
$mech->submit_form( ...
Published 2 years, 3 months ago
http://digitalpbk.blogspot.com/2007/05/custom-extenstion-for-server-script.html
Custom extenstion for a Server Script
Intro
PHP files have a &q
uot;.PHP" extension and is by default the extension used to run
php scripts. Thats ordinary. Now it would be cool if we could name another extension (say .do or .html) for a
PHP script and get the same output. This is precisely what the following is about.In order to map a particular extension to a particular application, apache uses handlers. Basically you can define an extension and add the corresponding handler. This can ...
Published 4 years, 12 months ago
http://digitalpbk.blogspot.com/2006/12/setting-up-apache-php-on-windows.html
Setting up Apache-
PHP on windows.
Step 1 : Downloading required files. apache server binaries : httpd.apache.orgphp binaries : www.
php.netStep 2 : Install apache server. Installing apache server is pretty much simple, and same as any other installation. Just enter a network domain name and server name and some email id (someone@microsoft.com). Then choose a installation directory : for reference i am using "C:\". Note that a directory called apache2 will be created under C:\ .So ...
Published 5 years, 4 months ago
http://digitalpbk.com/perl/solve-netmysql-hang-problem-if-database-result-has-only-1-row-or-empty
. If the result set is having just one row MySQL returns FE 00 00 02 00. The function on Net::MySQL package checks for end of packet and fails to find if the result set has only 1 row.
# Line 460
sub _has_next_packet
{
my $self = shift;
return
substr($_[0], -5) ne "\xfe\0\0\x22\x00";
}
Thus the Perl module loops back and waits for more data from the server, thus the blocking socket call to recv
makes the script hang.
Solve Net::MySQL Hanging Problem
In order to solve this problem use ...
Published 2 years, 1 month ago
http://digitalpbk.com/php/warning-cannot-modify-header-information-headers-already-sent
Solve "Cannot modify header information - headers already sent by *.
php"
Warning: Cannot modify header information - headers already sent by somefile.
php (output started at somefile.
php:###) in somefile.
php on line ###
This Warning is shown by
PHP when you use the header function to output headers or use the setcookie function to set cookies after any echo or content which is not inside
PHP tag.
Hello World !!!
Both should throw this warning.
You can disable ...
Published 2 years, 2 months ago
Related help topics for substr file_get_contents php
More keywords like substr file_get_contents php
More pages for substr file_get_contents php