POO with PHP $_POST

Asked

Viewed 556 times

1

How It Should Be Done for a Super Global $_POST Value To Enter a Class.

I’ve tried several ways, but without success. This value will be dealt with within the class.

  • 1

    Put in the code you already have

  • By the little that gave to understand of the question, you want to take a data past via post, and build an object with it? Using class methods and/or functions, this would be?

  • Not naverdade. Naverdade make him enter the class. I’ve managed to do this by going through parameter and show. However, when applying Pagsegurotransactionsearchservice::searchByCode($credentials, $transaction_code); ($transition_code must come from POST ) does not work. But if I’m in the class, then it works.

1 answer

0

Redeem the parameter received by the post method

$transaction_code = $_POST['transaction_code'];

Once done, pass to the class method parameter:

PagSeguroTransactionSearchService::searchByCode($credentials, $transaction_code);

Full example

<?php
$transaction_code = $_POST['transaction_code'];
PagSeguroTransactionSearchService::searchByCode($credentials,$transaction_code); 
  • 1

    This section "Full example" is just to fill sausages, to say that there is content in the answer.. rsrs

  • this is the kind of topic "box of surprises".. rsrs to each post a surprise that complements the question.. Look, if it falls in the catch, error message should appear. Is there an error message? Which one ? And ... so, it would have been better to have put the code in your question and not in my answer.. It got very strange.

  • Really it is a post "box of surprises" the author asks about PDO and then he spoke about Pagseguro, ie the question is poorly formulated rs. But I believe that your answer helps this question not to be closed, I only recommend you edit the question, so that your answer does not look like "invalid". (I believe you already have editing power)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.