Jump to content

class functions


momanroman
Go to solution Solved by Ch0cu3r,

Recommended Posts

Apologies if this is simples.

I'm adapting an ecommerce payment module, which comes as a class.

 

I have written some extra code (as a function) to strip the numbers from a  postcode & addess for card verification purposes.

 

My issue is I cannot test this very easily live so I need to know the syntax is mostly correct.

 

For example. (structure only, most code stripped)

 

 

 

 class payment module {
    var $code, $title, $description, $enabled;


// class constructor
    function moduleconst() {
 

// constructor code in here

                                         }

// class methods

    function method1() {
 

//  code in here

                                  }

 

    function method2() {
 

//  code in here

                                  }

  }

 

My problem is simple, how do I call function1 from within function2? Can I just call it straight ?

 

ie:

 

    function method2() {
 

                                      method1();

                                  }

 

Iain

 

 

 

Link to comment
Share on other sites

My issue is I cannot test this very easily live so I need to know the syntax is mostly correct.

Are you saying you do not have a development environment to test your code changes before pushing live? Do you really think it's a good idea to push untested changes live, especially when money stuff is involved??

 

Pushing untested code into production should NOT be an option, period. Especially when there is a user's personal info and/or money involved.

 

But in any case, you call like this:

 

$this->method1();
Link to comment
Share on other sites

Hi,

 

Yes there is a dev/test envirovent but that would mean cloning the whole site and database to use, something I am trying to avoid.

 

I have tested my function already and it is rock solid, it is a fairly straight forware regex function from the post code.

 

Its already been integrated into the module with no error, I just need to call it, job done, I beleive, we shall see.

Link to comment
Share on other sites

Hi,

 

Yes there is a dev/test envirovent but that would mean cloning the whole site and database to use, something I am trying to avoid.

 

I have tested my function already and it is rock solid, it is a fairly straight forware regex function from the post code.

 

Its already been integrated into the module with no error, I just need to call it, job done, I beleive, we shall see.

 

Can you please share the site that you are working on? I want to make sure to never visit it.

 

You state there is a dev/test environment but that you would have to clone the whole site and database. If there is a dev/test environment then doesn't it already have the code and DB for the site?. Otherwise the dev/test environment isn't serving it's purpose. Well, actually you need several such environments - including a stage environment. My company has very strict rules about code progression to production as well as a full auditing system for code check-in and test sign off. Every once in a while someone says there is a 'simple' fix with little to no regression risk that has to get put out without going through the process. More often then not it causes more problems than it was supposed to resolve.

 

FYI: You should NEVER clone production data to your test environments - big no, no. The code is fine, but the database should not. There needs to be processes in place so that the access to the production database is limited to only those individuals that must have it. If data is needed from production,troubleshooting for example, then the specific data should be retrieved w/o any user personal information. Or, if that information is needed, there must be an audit process.

Edited by Psycho
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.