Created: 18/10/2022
By: W3 Programmings
Email: w3programmings@gmail.com
Thank you for purchasing our script. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here. Thanks so much!
PHP Starter Helper Functions Kit is a carefuly chosen and commenly used PHP functions, with aim to speedup the development.
It is very easy to use, highly customizable and well documented.
It supports all following PHP versions:
Following are the high level features supported by this script:
Include this single file "functions.php" on the top or in the main config file of your project.
<?php
include('file/path/to/functions.php');
?>
Please open "index.php" to see the reference of each function with an example and use.
A reference is below:
Create meta page title
<?php
echo metaTitle('My Site Title');
// Output: <title>My Site Title</title>
?>
Create meta page description
<?php
echo metaDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
// Output: <meta name="description" content="Lorem ipsum dolor sit amet, consectetur adipiscing elit." />
?>
Create meta page keywords
<?php
echo metaKeywords('Lorem, ipsum, dolor');
// Output: <meta name="keywords" content="Lorem, ipsum, dolor" />
?>
Display HTML code as it is in the browser without executing the tags
<?php
echo displayHtml('<p>Lorem Ipsum</p>');
// Output: <p>Lorem Ipsum</p>
?>
Encode the encoded HTML to store safely in the database
<?php
echo encodeHtml('<p>Lorem Ipsum</p>');
// Output: <p>Lorem Ipsum</p>
?>
Decode back the encoded HTML into browser's readable format
<?php
echo decodeHtml('<p>Lorem Ipsum</p>');
// Output: <p>Lorem Ipsum</p>
?>
Remove HTML tags from a string
<?php
echo escapeHtml('<p>Lorem Ipsum</p>');
// Output: Lorem Ipsum
?>
Create SEO friendly URL from a title or text string
<?php
echo sluggify('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
// Output: lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit
?>
Encrypt a text in bcrypt hash format. Best for using in passwords
<?php
echo bcrypt('W3Programmings');
// Output: $2y$10$KJwjUevlfbTLYcIj2ysxKOcF.AK9fVFbVUv6wSj8CHAIrOsdgB28K
?>
Verify passwords entered from user login form and the database. Use case: user login
<?php
// password from user
$post = 'W3Programmings';
// password from database
$pwd_db = '$2y$10$KJwjUevlfbTLYcIj2ysxKOcF.AK9fVFbVUv6wSj8CHAIrOsdgB28K';
if(verify_password($post, $pwd_db) == true){
echo "Verified";
}
else {
echo "Not verified";
}
// Output: verified
?>
Enable file upload attribute in the form tag
<?php echo '<form method="post" action="#" '.allowFileUpload().'>'; // Output: <form method="post" action="#" enctype="multipart/form-data" > ?>
Upload single file. Use this function in file process
<?php
$file = 'userProfile'; // input file type name
$dir = 'uploads'; // uploads folder
// use this function in file process
$response = uploadFile($file, $dir);
if($response) {
// success
echo $response; // uploaded file name
} else {
// error
echo "Error! File could not moved to destination";
}
// Output: it returns file name upon successful file upload
?>
Get file extension
<?php
echo getFileExtension('/uploads/users/my_pic.jpg');
// Output: jpg
?>
Get file mime type
<?php
echo getFileMime('/uploads/users/my_pic.jpg');
// Output: image/jpeg
?>
Limit string to a defined length
<?php
echo limitString('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 10);
// Output: Lorem ipsu
?>
Limit string and display read more
<?php
echo limitStringWithReadMore('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 10);
// Output: Lorem ipsu... read more
?>
Create a numeric loop - usecase age dropdown
<?php
echo integerOptions('age', 5, 10); // pass 4th value to show it selected
// Output:
<select id="select_age" name="age" class="form-control">
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
?>
Create a gender dropdown
<?php echo genderOptions(); // Output: <select id="gender" name="gender" class="form-control"> <option value="Male">Male</option> <option value="Female">Female</option> <option value="Transgender">Transgender</option> </select> ?>
Convert a date into friendly date
<?php
echo friendlyDate(date('dmy'));
// Output: Oct 16, 2022
?>
Get month name by month number (1-12)
<?php echo monthName(7); // Output: July ?>
Get country code by IP address
<?php
echo getCountryCodeByIp('39.42.64.11');
// Output: PK
?>
Get country name by IP address
<?php
echo getCountryNameByIp('39.42.64.11');
// Output: Pakistan
?>
Get continent code by IP address
<?php
echo getContinentCodeByIp('39.42.64.11');
// Output: AS
?>
Get timezone by IP address
<?php
echo getTimezoneByIp('39.42.64.11');
// Output: Asia/Karachi
?>
Get country list dropdown
<?php echo countryList(); // pass country name to show it selected e.g. Pakistan // Output: country dropdown ?>
Get a number in decimal with desired decimal length
<?php echo decimals(100.24568, 2); // Output: 100.25 ?>
Find percentage of a number, from a number
<?php echo percentage(25, 50); // Output: 50 ?>
Roundoff a number
<?php echo roundOff(-4.42); // Output: -4 ?>
Remove minus sign from a number
<?php echo absoluteNum(-4.42); // Output: 4.42 ?>
Print a message in the console through PHP (used as live logger)
<?php
consoleLog('We are w3programmings');
// Output: print in console
?>
Remove empty element or 0 from array
<?php
print_r(filterZero(array('1','2','3','40','1','2','0')));
// Output: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 40 [4] => 1 [5] => 2 )
?>
Get IP address
<?php echo getIp(); // Output: 39.42.64.11 ?>
Find count of a number in array
<?php
echo array_count_values_of(array('2.5', '3.5', '4', '3.5'), '3.5');
// Output: 2
?>
Check if 2 arrays are equal or have same elements
<?php
if(array_equal(array(51,4), array(4,51))){
echo "equal";
}
else{
echo "not equal";
}
// Output: equal
?>
Get country name by IP address
<?php
echo (ipInfo('39.42.64.11', "Country"));
// Output: Pakistan
?>
Get country code by IP address
<?php
echo (ipInfo('39.42.64.11', "Country Code"));
// Output: PK
?>
Get state by IP address
<?php
echo (ipInfo('39.42.64.11', "State"));
// Output: Punjab
?>
Get city by IP address
<?php
echo (ipInfo('39.42.64.11', "City"));
// Output: Lahore
?>
Get address by IP address
<?php
echo (ipInfo('39.42.64.11', "Address"));
// Output: Lahore, Punjab, Pakistan
?>
Get location service by IP address
<?php
print_r(ipInfo('39.42.64.11'));
// Output:
// Array (
// [city] => Lahore
// [state] => Punjab
// [country] => Pakistan
// [country_code] => PK
// [continent] => Asia
// [continent_code] => AS
// );
?>
Get user location by IP address
<?php
echo getVisitorLocation('39.42.64.11');
// Output: Hello visitor from Pakistan, Lahore!
?>
Encrypt a string
<?php
echo encryptor('encrypt', 'w3programmings');
// Output: NUMyeFU1L2Q1bEs4S2oyTFE1V3dsUT09
?>
Decrypt a string
<?php
echo encryptor('decrypt', 'NUMyeFU1L2Q1bEs4S2oyTFE1V3dsUT09');
// Output: w3programmings
?>
Get today date
<?php echo getTodayDate(); // pass format (default Y/m/d) // Output: 2022/10/16 ?>
Encode the URL
<?php
echo encodeURIComponent('https://www.google.com/');
// Output: https%3A%2F%2Fwww.google.com%2F
?>
Decode the URL
<?php
echo decodeURIComponent('https%3A%2F%2Fwww.google.com%2F');
// Output: https://www.google.com/
?>
Create dynamic dropdown
<?php
$dropdown_values = array('Apple','Mango','Orange','Pineapple','Grapes');
// name, array values, selected value
echo generate_dropdown('stage', $dropdown_values, 'Orange');
// Output:
<select id="select_stage" name="stage" class="form-control">
<option value="Apple">Apple</option>
<option value="Mango">Mango</option>
<option value="Orange" selected="selected">Orange</option>
<option value="Pineapple">Pineapple</option>
<option value="Grapes">Grapes</option>
</select>
?>
Create month dropdown
<?php echo monthDropdown(); // pass 1-12 to select months // Output: months dropdown ?>
Calculate difference of 2 dates (in days)
<?php
echo dateDifference("2022-06-15", "2022-12-12");
// Output: 180
?>
Extract year from date
<?php
echo extractYear("2022-06-15");
// Output: 2022
?>
Extract month from date
<?php
echo extractMonth("2022-06-15");
// Output: 06
?>
Extract day from date
<?php
echo extractDay("2022-06-15");
// Output: 15
?>
Create a back button that uses history.back()
<?php echo backButton(); // Output: // <button type="button" class="btn btn-primary" onclick="history.back();"><i class="fa fa-arrow-left"></i> Back</button> ?>
Convert array into json format
<?php
$array = array('Apple','Mango','Orange','Pineapple','Grapes');
echo arrayToJson($array);
// Output: ["Apple","Mango","Orange","Pineapple","Grapes"]
?>
Convert string into camel case
<?php
echo toCamelCase('hello world is the first program');
// Output: Hello World Is The First Program
?>
Convert string into snake case
<?php
echo toSnakeCase('hello world is the first program');
// Output: hello_world_is_the_first_program
?>
Convert fahrenheit to celsius
<?php echo fahrenheitToCelsius(113); // Output: 45 ?>
Convert fahrenheit to kelvin
<?php echo fahrenheitToKelvin(41); // Output: 278.15 ?>
Convert celsius to fahrenheit
<?php echo celsiusToFahrenheit(113); // Output: 235.4 ?>
Convert celsius to kelvin
<?php echo celsiusToKelvin(45); // Output: 318.15 ?>
Convert kelvin to fahrenheit
<?php echo kelvinToFahrenheit(334); // Output: 141.53 ?>
Convert kelvin to celsius
<?php echo kelvinToCelsius(280); // Output: 6.85 ?>
Generate uuid
<?php echo uuid_v4(); // Output: c49ebbde-68d0-4a23-9b5b-e4f8833cd273 ?>
Generate random alphabets upto (n) length
<?php echo randomAlphabets(10); // Output: dSfsYoNLuy ?>
Generate random alphanumeric upto (n) length
<?php echo randomAlphaNumeric(12); // Output: ee2db9d94e2f ?>
Generate 6 digit random number
<?php echo randomNumber(); // Output: 470974 ?>
Get URL of current page
<?php echo returnURL(); // Output: https://w3programmings.com/products/php-starter-kit/ ?>
Remove white space from the start and end of string
<?php
echo trimWhiteSpace(' w3programmings ');
// Output: w3programmings
?>
Remove white space from entire string
<?php
echo removeWhiteSpace(' w3 programmings ');
// Output: w3programmings
?>
Remove special character from a string
<?php
echo removeSpecialCharacter('@w3$prog$rammi!ngs$');
// Output: w3programmings
?>
Remove any character from a string
<?php
echo removeCharacter('@', '@w3@prog@rammings@');
// Output: w3programmings
?>
Randomly shuffle all characters of a string
<?php
echo shuffleText('w3programmings');
// Output: p3aimwgrrsognm
?>
Count words from a string
<?php
echo countWords('hello world is the first program');
// Output: 6
?>
Generate QR code image
<?php
echo qrCode('https://w3programmings.com');
// Output: generates a QR code
?>
Once again, thank you so much for purchasing this sript. As we said at the beginning, we'd be glad to help you if you have any questions relating to this script. No guarantees, but we'll do our best to assist. If you have a more general question relating to the themes on CodeCanyon, you might consider visiting the forums and asking your question in the "Item Discussion" section.
W3 Programmings