Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

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 ]

[Page 1]  [Page 2]  


Comments:
RE: How to Link Mysql with vbshyan06/21/05 05:05
PHP to .netAnjali 06/08/05 01:33
RE: How to Link Mysql with vbJayson Guillermo05/01/05 01:42
RE: PHP filesSean Redfearn11/24/04 05:34
Good to see ur siteAbhishek11/06/04 09:07
Rewriting FunctionsManutius12/02/03 03:25
RE: PHP editor for linux?Herman Tolentino05/14/03 11:00
How to Code ASP "Includes" in PHPLiz01/24/03 21:47
conversion of ASP dll's Mike11/05/02 21:24
VB to PHP conversionRussel10/23/02 05:08
PHP editor for linux?rnj10/18/02 22:21
RE: font function not neededMichael08/03/02 20:51
RE: Dangerous people...Scott Carr07/30/02 15:43
RE: Victoria Bitter (VB)Terrent06/25/02 08:36
RE: VB v/s PHPSimone Capra04/21/02 08:29
Patchingcool keith02/24/02 16:27
RE: How to Link Mysql with vbSly02/13/02 10:18
RE: VB v/s PHPRicky Dean01/25/02 02:05
RE: VB/ASP -> PHPRichard Lanham01/21/02 07:39
RE: PHP filesAndy01/16/02 21:54
PHP? VB? Whatever..Jalal Maqdisi01/13/02 09:05
Call to undefined function: mssql_connect() stef11/27/01 07:49
RE: How to Link Mysql with vbd n g11/19/01 03:38
RE: How to Link Mysql with vbLucian11/12/01 07:55
How to Link Mysql with vbImthiaz11/01/01 23:24
RE: PHP and VBchad10/11/01 14:00
i need a code to put one "news.html" in my hphugo10/03/01 12:59
PHP(under Windows) and VBI.Silviu09/16/01 17:31
RE: font function not neededMatt08/17/01 06:44
PHP filesSanchu07/09/01 04:49
font function not neededMark06/23/01 06:59
GREAT!!!Jack Saunders05/09/01 08:43
RE: PHP vs. VBDave05/01/01 05:07
Homesite correctionDaniel Keep04/16/01 04:40
PHP vs. VBGeorge Ob04/10/01 11:00
RE: VB v/s PHPLee04/07/01 10:57
RE: Dangerous people...Charlie03/21/01 14:14
RE: Hardest aspect for meSonOfDad03/09/01 10:16
RE: Victoria Bitter (VB)Devon02/23/01 14:36
RE: Victoria Bitter (VB)Jesus H' Linux01/29/01 12:26
RE: VB v/s PHPJesus H' Linux01/29/01 12:16
RE: Victoria Bitter (VB)Peter Moulding01/11/01 19:22
RE: VB v/s PHPPeter Moulding01/11/01 19:06
RE: Hardest aspect for mePeter Moulding01/11/01 18:51
Hardest aspect for meMike01/10/01 04:54
VB/ASP -> PHPAra01/07/01 02:55
RE: VB v/s PHPDigital Wokan01/02/01 17:51
VB v/s PHPDavid Greene12/28/00 21:58
PHP and VBPeter Dove12/04/00 13:29
RE: Victoria Bitter (VB)Mark Saunders11/16/00 22:41
Victoria Bitter (VB)Louis Zezeran11/02/00 06:35
RE: PHP and VBNeil p Davis10/23/00 12:32
RE: RE: Dangerous people...George Herson07/20/00 22:11
RE: Dangerous people...Tim Perdue, PHPBuilder.com07/13/00 12:03
PHP and VBEdward Brown07/06/00 11:23
Dangerous people...Luis Argerich06/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.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.