PHP code example of jayeshmepani / swiss-ephemeris-ffi
1. Go to this page and download the library: Download jayeshmepani/swiss-ephemeris-ffi library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jayeshmepani / swiss-ephemeris-ffi example snippets
use SwissEph\FFI\SwissEphFFI;
$sweph = new SwissEphFFI();
$jd = $sweph->swe_julday(2000, 1, 1, 12.0, SwissEphFFI::SE_GREG_CAL);
$xx = $sweph->getFFI()->new("double[6]");
$serr = $sweph->getFFI()->new("char[256]");
$result = $sweph->swe_calc_ut(
$jd,
SwissEphFFI::SE_SUN,
SwissEphFFI::SEFLG_SPEED,
$xx,
$serr
);
if ($result >= 0) {
echo "Sun Longitude: " . $xx[0] . "°\n";
} else {
echo "Swiss Ephemeris error: " . $sweph->getFFI()->string($serr) . "\n";
}