How to write better php code
A colegue showed me a great article about how to write better code in php / optimizing php code. It has 40 tips for doing this.
Here are the first 10:
- liviu's blog
- Login or register to post comments
- Read more
Automating documentation for php scripts - phpDocumentor
At my old job, i found out about phpDocumentor.
If you get used to their way of writing comments, it can automatically write documentation for your code. It could be a very useful tool, specially for big projects.
- liviu's blog
- Login or register to post comments
A trick from metrolyrics.com to get more inbound links (and traffic maybe)
metrolyrics.com is a lyrics site. I saw on their site that they are offering for every song/lyrics a nice flash and the code to embed it on your site.
The code looks like this:
- liviu's blog
- Login or register to post comments
- Read more
How to replace a url with a link to it with regular expressions
If you want to replace all the url's in a text with a link to them you should do something like this:
$text = preg_replace'@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
- liviu's blog
- Login or register to post comments
Paypall in Romania
In 2007 PayPal started accepting transactions to and from Romania. There is an interesting conversation (in Romanian) about this here: http://forum.softpedia.com/index.php?showtopic=243638&st=510
- liviu's blog
- Login or register to post comments
How to get the size of an array in php
To see the size of an array in php you use count($array).
$arraySize = count($tag);
for ($i = 0; $i < $arraySize; $i++)
{
...
}
It also works to see how many properties there are in an object.
- liviu's blog
- Login or register to post comments
mysql: How to see how many elements a result has
To see how many elements a mysql result has in php you use mysql_num_rows like so:
$query="select * from news where a=1 order by id desc";$result=mysql_query($query);if (mysql_num_rows ($result) == 0){ echo 'no news has been added yet'
}
else { while($row=mysql_fetch_array($result)) {
......
}}
- liviu's blog
- Login or register to post comments
Directory scripts
I was searching one day for a script/cms for a directory. Here are some options i found:
phplinkdirectory
Site Sift Listings
eSyndiCat
freephpdirectoryscript
Wsn-Links
PowerSeek
- liviu's blog
- Login or register to post comments
How to get video ads from adsense
Usually people like and click more on the video ads. But Adsense decides what kind of ad will be on your site. So what can you do to increase your chances to get a video ad?
Well first you have to allow for image ads i think when you create the ad.
Second you have to have the correct ad size for video.
What are the adsense video format sizes?
Leaderboard (728x90)
Skyscraper (120x600)
Wide skyscraper (160x600)
Small Square (200x200)
Square (250x250)
Rectangle (300x250)
- liviu's blog
- Login or register to post comments
- Read more
How to get the id of an inserted mysql row in php
This saved me a lot of work after i found out about it. After you insert a row in a mysql table, you can get the id that was automatically created using this php funtion: mysql_insert_id ([ resource $link_identifier ] ).
mysql_insert_id — Get the ID generated from the previous INSERT operation
int mysql_insert_id ([ resource $link_identifier ] )
- liviu's blog
- Login or register to post comments
- Read more