php

php - make youtube embed code from an url

Tagged:  

A small php function that transforms a youtube url in its embed script.

Php include_once equivalent for javascript

Tagged:  

This one time, in band camp, when i was working on a javascript... script i needed an equivlent for the include_once in php. It was very likely that the code where i was including something got to run multiple times, and this caused problems.
So i found the solution on phpied.com.
So here it is, the php include_once equivalent for javascript:

var included_files = new Array();

function include_once(script_filename)
{

Php functions in javascript

Tagged:  

A bunch of nice people started a project where they port php functions (eg: addslashes) to javascript. So if you have experience in php and you think at some point "I wish i would have this php function in javascript" you might be lucky enough to find it on their site. When i wrote this they ported 399 functions.

Tips for speeding up php scripts

Tagged:  

Taken from

Programming PHP, 2nd Edition

By Rasmus Lerdorf, Peter MacIntyre, Kevin Tatroe

Optimizing Execution Time
Here are some tips for shortening the execution times of your scripts:

php security tips

Tagged:  

Again from the book

A good free php book

Tagged:  

I was reading a good free php book to remind me some php things.
It covers things in php 5.
It's called

How to see php errors in firebug

Tagged:  

If you want to see php errors in firebug here is how you do it: <?php
 
/**
* class: Debugger
* author: <a href="http://doru.serveblog.net">Moisa Doru</a>
* contact: <a href="mailto:moisadoru@gmail.com">moisadoru@gmail.com</a>
* info: this class displays PHP errors in Firebug; works only in PHP5, tested in PHP 5.2.0
* usage: <strong>include_once("debugger.php")</strong> as the very first include();
* licence: free as in free beer ;)
*/
 

A nice way to get the value of a $_GET in php

Tagged:  

Here is a nice way to get the value of a $_GET in php (i think it will also work with $_POST)

function get($value)

{
   $valoare = isset($_REQUEST[$value]) ? addslashes(strip_tags($_REQUEST[$value])) : '';
   return $valoare;
}

 

How to block an ip from viewing your adsense ads

Tagged:  

I saw this here i think.
It's a simple way to block certain ip's you might suspect want to give you invalid clicks to get you banned in adsense.
Of course first you have to have a list of ip's you suspect to be ill intentioned, and that isn't very likely to happen in the real world, but if you do, here is what you could do.

How to reindex an array in php

Tagged:  

If you have an array and want to reindex it to have the keys starting from 0 and be consecutive, you can use array_values, which does just that.

You can use it when lets say you want to iterate through it with a for (and not a foreach).

Syndicate content