Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
How to echo variable value outside of the function in WordPress
<?php
function ybr_client_results(){
    $client_details = $_POST['client_details'];
    die();
}
add_action('wp_ajax_ybr_client_results', 'ybr_client_results');

?>

How to echo this $client_details value outside of the function

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Try to use global variable

Example

$client_details = "";
function ybr_client_results(){
    global $client_details;
    $client_details = $_POST['client_details'];
    die();
}
add_action('wp_ajax_ybr_client_results', 'ybr_client_results');
over 4 years ago · Santiago Trujillo Report

0

Like this:

<?php
$client_details = "";
function ybr_client_results(){
    $client_details = $_POST['client_details'];
    die();
}
echo $client_details;
add_action('wp_ajax_ybr_client_results', 'ybr_client_results');

?>
over 4 years ago · Santiago Trujillo Report

0

You have to create variable outside of function, and in function you have to create same name variable with global.

<?php
$client_datails;
function ybr_client_results(){
    global $client_details;
    $client_details = $_POST['client_details'];
    die();
}
add_action('wp_ajax_ybr_client_results', 'ybr_client_results');
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!