Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6671119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:20:59+00:00 2026-05-26T03:20:59+00:00

By default php returns NULL for function that doesn’t do anything. For example: 1

  • 0

By default php returns NULL for function that doesn’t do anything.

For example:

1 <?php
2 
3 function foo() {
4     // Nothing here
5 }
6
7 var_dump(foo()); // the result will be NULL

I’m trying to implement an function that will have direct output and i don’t need to return anything from inside the function, i what to obtain something like:

void var_dump()// it just only dumps information.

My function will generate a image but will not return any information. The image will be generated, after processing, using ImageJpeg($image) inside the function. The signature in php manual for imageJpeg is:

imagejpeg — Output image to browser or file

in this way I’ll have output image and NULL returned from function. How can i avoid that. How can i obtain ONLY output image?

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:21:00+00:00Added an answer on May 26, 2026 at 3:21 am

    The PHP equivalent of a void function foo() is a regular function that simply has no return statement. Whether this function outputs anything or not is completely independent of that. A function may output something in any variety of ways and return a value, or either or neither. In concrete terms, this is a function with no return value which outputs an image:

    function foo() {
        ...
        imagejpg(...);
    }
    
    foo();
    

    What you may be confusing here is the difference between a return value and output. The output is what the program finally outputs to the user/stout/php://output. A function return value is what the function returns to the caller.

    function foo() {
        echo 'Hello World';
        imagejpg(...);
        return 'foo';
    }
    
    $bar = foo();
    

    This function visibly prints “Hello World” on your screen followed by some binary image. The function returns the string 'foo' and the variable $bar now holds 'foo', but this is not output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I am working on a PHP file for example the default filetype is
Should I frequently rely on default values? For example, in PHP, if you have
The most recent comment on PHP's in_array() help page ( http://uk.php.net/manual/en/function.in-array.php#106319 ) states that
For some reason the item description returns NULL with the following code: <?php include('db.php');
I have a query that returns as a result what seems to be a
My server have default php version of 4, so when I run some script
PHP uses magic quotes by default but has gotten a lot of flak for
For PHP, what is the default time after which an HTTP request is deemed
I am doing the following in PHP: exec('java -jar /opt/flex3/lib/mxmlc.jar +flexlib /opt/flex3/frameworks MyAS3App.as -default-size
<script type='text/javascript'> $(document).ready(function() { $(#specific_consultant_yes).click(function() { $('.specific').show('slow'); $.post(<?php echo $this->url(array('controller'=>'appointment', 'action' =>'available'),'default',true)?>,{app_date:$(#App_date).val(),consultant:$(#Consultants).val()} ,function(data){ $(.new).html(data);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.