|
Switching From VB to PHP
Switching from VB to PHP is half way between the bicycle-to-car switch
and the car-to-car switch. Most things look different so I can remember
which language I am using. One really tricky part is remembering the weird
options on substr(). While substr() is powerful, VBs left(), right() and
mid() are easier to learn. If a programmer has to regularly swap between VB
and PHP, he/she will spend a lot of time looking up the parameters for
substr(). The tip outlined below simply removes the problem.
Here are my favorite examples of instant help:
<?php
Function len($lenstring) {
return(strlen($lenstring));
}
// Neat and simple. It lets me grab the length of
// a string exactly how I would in VB:
$x = len($y);
Function left($leftstring, $leftlength) {
return(substr($leftstring, 0, $leftlength));
}
// It lets me grab 1 or a few characters from
// the front of a string exactly how I would in VB.
Function mid($midstring, $midstart, $midlength="") {
if (len($midlength)) {
return(substr($midstring, $midstring-1, $midlength));
} else {
return(substr($midstring, $midstring-1));
}
}
/*
A little more programming to emulate VB. Mid() is a function I often
use to emulate the sophisticated VB functions that are, sadly, restricted
to only a few versions of VB.
*/
function right($rightstring, $rightlength) {
return(substr($rightstring, -$rightlength));
}
// This is the left function translated for right wingers.
?>
I think you have the idea now. Where something is similar but confusing,
write a function in the new language to emulate the old. In some cases the
process of writing the function will help you learn the new language to the
point where you may never use the emulation function.
[ Next Page ]
| Comments: | ||
| RE: How to Link Mysql with vb | shyan | 06/21/05 05:05 |
| PHP to .net | Anjali | 06/08/05 01:33 |
| RE: How to Link Mysql with vb | Jayson Guillermo | 05/01/05 01:42 |
| RE: PHP files | Sean Redfearn | 11/24/04 05:34 |
| Good to see ur site | Abhishek | 11/06/04 09:07 |
| Rewriting Functions | Manutius | 12/02/03 03:25 |
| RE: PHP editor for linux? | Herman Tolentino | 05/14/03 11:00 |
| How to Code ASP "Includes" in PHP | Liz | 01/24/03 21:47 |
| conversion of ASP dll's | Mike | 11/05/02 21:24 |
| VB to PHP conversion | Russel | 10/23/02 05:08 |
| PHP editor for linux? | rnj | 10/18/02 22:21 |
| RE: font function not needed | Michael | 08/03/02 20:51 |
| RE: Dangerous people... | Scott Carr | 07/30/02 15:43 |
| RE: Victoria Bitter (VB) | Terrent | 06/25/02 08:36 |
| RE: VB v/s PHP | Simone Capra | 04/21/02 08:29 |
| Patching | cool keith | 02/24/02 16:27 |
| RE: How to Link Mysql with vb | Sly | 02/13/02 10:18 |
| RE: VB v/s PHP | Ricky Dean | 01/25/02 02:05 |
| RE: VB/ASP -> PHP | Richard Lanham | 01/21/02 07:39 |
| RE: PHP files | Andy | 01/16/02 21:54 |
| PHP? VB? Whatever.. | Jalal Maqdisi | 01/13/02 09:05 |
| Call to undefined function: mssql_connect() | stef | 11/27/01 07:49 |
| RE: How to Link Mysql with vb | d n g | 11/19/01 03:38 |
| RE: How to Link Mysql with vb | Lucian | 11/12/01 07:55 |
| How to Link Mysql with vb | Imthiaz | 11/01/01 23:24 |
| RE: PHP and VB | chad | 10/11/01 14:00 |
| i need a code to put one "news.html" in my hp | hugo | 10/03/01 12:59 |
| PHP(under Windows) and VB | I.Silviu | 09/16/01 17:31 |
| RE: font function not needed | Matt | 08/17/01 06:44 |
| PHP files | Sanchu | 07/09/01 04:49 |
| font function not needed | Mark | 06/23/01 06:59 |
| GREAT!!! | Jack Saunders | 05/09/01 08:43 |
| RE: PHP vs. VB | Dave | 05/01/01 05:07 |
| Homesite correction | Daniel Keep | 04/16/01 04:40 |
| PHP vs. VB | George Ob | 04/10/01 11:00 |
| RE: VB v/s PHP | Lee | 04/07/01 10:57 |
| RE: Dangerous people... | Charlie | 03/21/01 14:14 |
| RE: Hardest aspect for me | SonOfDad | 03/09/01 10:16 |
| RE: Victoria Bitter (VB) | Devon | 02/23/01 14:36 |
| RE: Victoria Bitter (VB) | Jesus H' Linux | 01/29/01 12:26 |
| RE: VB v/s PHP | Jesus H' Linux | 01/29/01 12:16 |
| RE: Victoria Bitter (VB) | Peter Moulding | 01/11/01 19:22 |
| RE: VB v/s PHP | Peter Moulding | 01/11/01 19:06 |
| RE: Hardest aspect for me | Peter Moulding | 01/11/01 18:51 |
| Hardest aspect for me | Mike | 01/10/01 04:54 |
| VB/ASP -> PHP | Ara | 01/07/01 02:55 |
| RE: VB v/s PHP | Digital Wokan | 01/02/01 17:51 |
| VB v/s PHP | David Greene | 12/28/00 21:58 |
| PHP and VB | Peter Dove | 12/04/00 13:29 |
| RE: Victoria Bitter (VB) | Mark Saunders | 11/16/00 22:41 |
| Victoria Bitter (VB) | Louis Zezeran | 11/02/00 06:35 |
| RE: PHP and VB | Neil p Davis | 10/23/00 12:32 |
| RE: RE: Dangerous people... | George Herson | 07/20/00 22:11 |
| RE: Dangerous people... | Tim Perdue, PHPBuilder.com | 07/13/00 12:03 |
| PHP and VB | Edward Brown | 07/06/00 11:23 |
| Dangerous people... | Luis Argerich | 06/30/00 16:33 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


