Displays native popup dialog boxes for PHP CLI on Linux/BSD and Windows desktops.
// OK button
function popup_warning ( string $MESSAGE , string $TITLE = NULL ) : bool ;
function popup_error ( string $MESSAGE , string $TITLE = NULL ) : bool ;
// YES / NO buttons
function popup_question( string $MESSAGE , string $TITLE = NULL ) : bool ;
// OK button
function popup_info( string $MESSAGE , string $TITLE = NULL , string $TYPE = POPUP_INFO ) : bool ;If $TITLE is left to NULL, the name of the main PHP script will be used as title for the dialog box.
<?php
include("popup.php");
popup_warning( "I'm going to ask you a question!" , "WARNING" );
if ( popup_question( "Are you ready?", "The question is ..." ) )
{
popup_info( "The user is ready.", "Confirmation" );
}
else
{
popup_error( "The user is not ready." , "ERROR" );
}If the script can't call a native OS or desktop dialog box, it will fallback to terminal user input.
On Windows :
- if the PHP module FFI is available, will call
MessageBoxW()and will try to useiconv - else, fallback to
readline() - else, error.
On Linux/BSD :
- file selection dialog box
- text input dialog box